Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Function: _exit(Canvas &canvas, int flag)
- Description: Based on the input flag, the game gets ended with a win or loss and
- draws onto canvas the end game messesge. Once drawn, exit() gets called
- which tells the OS to safely shut down this program.
- Input: Canvas object and an intager flag indicated how to exit (won or lost).
- Output: Draws to canvas and ends the program.
- Error: None
- */
- void _exit(Canvas &canvas, int flag)
- {
- cout << "\t Thank you for playing! \n \t\t Exiting now\n";
- // Draw the 4 corners of the game done screen.
- int x = 150;
- int y = 150;
- for (int i = 0; i < 4; i++)
- {
- canvas.DrawFillRect(
- x, // Top left X position
- y, // Top left Y position
- 60, // Width in pixels
- 60, // Height in pixels
- 0.80, // Red value (0.0 - 1.0)
- 0.80, // Green value (0.0 - 1.0)
- 0.80 // Blue value (0.0 - 1.0)
- );
- x += 120;
- if (i==1)
- {
- x = 150;
- y = 270;
- }
- }
- // Light main square
- canvas.DrawFillRect(
- 180, // Top left X position
- 180, // Top left Y position
- 120, // Width in pixels
- 120, // Height in pixels
- 0.3, // Red value (0.0 - 1.0)
- 0.55, // Green value (0.0 - 1.0)
- 0.49 // Blue value (0.0 - 1.0)
- );
- // Based on what the input flag was, exit the maze with an appropriate
- // phrase.
- switch (flag)
- {
- case 0:
- canvas.DrawText(200,225,"Exiting Now");
- break;
- case 1:
- canvas.DrawText(200,225,"You Win!");
- break;
- case 2:
- canvas.DrawText(200,225,"You Died!");
- break;
- }
- // Forces canvas to redraw itself.
- canvas.Invalidate();
- // Wait four seconds so user can actually see the screen and
- // the "End Game" box.
- usleep(4000000);
- // Signal the OS to safely shut down this maze program.
- exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement