{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

assignment3 - Simple money calculator Images needed

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// This program demonstrates how to determine whether or not // the user has clicked on a sprite. #include "DarkGDK.h" # // Constants const int penny = 1; const int nickle = 2; const int dime = 3; const int quarter = 4; const int counter = 5; const int REFRESH_RATE = 60; // The refresh rate c const double pennyAmount = 1; const double nickleAmount = 5; const double dimeAmount = 10; const double quarterAmount = 25; float total; f // Function prototypes void setUp(); bool onSprite(int, int, int); bool mouseFullClick(int &, int &); b //************************************************************* // DarkGDK function * //************************************************************* void DarkGDK() { // Variables to hold the mouse pointer's // X and Y coordinates. int mouseX, mouseY; // Perform setup operations. setUp(); // Game loop while ( LoopGDK() ) { // Determine whether the user has clicked the // left mouse button. if ( mouseFullClick(mouseX, mouseY) ) { // Determine whether the user clicked on the coin. if ( onSprite(penny, mouseX, mouseY) ) { total += pennyAmount; } else if (onSprite(nickle, mouseX, mouseY)) { total += nickleAmount; } else if (onSprite(dime, mouseX, mouseY)) { total += dimeAmount; } else if (onSprite(quarter, mouseX, mouseY)) { total += quarterAmount; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}