Project Submission (late)

Dependencies:   mbed

Committer:
el17tc
Date:
Fri May 10 08:07:10 2019 +0000
Revision:
0:72f372170a73
Child:
3:83e79d31930c
Save at functioning version;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el17tc 0:72f372170a73 1 #ifndef VICTORYMENU_H
el17tc 0:72f372170a73 2 #define VICTORYMENU_H
el17tc 0:72f372170a73 3
el17tc 0:72f372170a73 4 #include "Menus.h"
el17tc 0:72f372170a73 5
el17tc 0:72f372170a73 6 // yes button used in the VictoryMenu and the DefeatMenu
el17tc 0:72f372170a73 7 class YesButton : public Button {
el17tc 0:72f372170a73 8 public:
el17tc 0:72f372170a73 9 YesButton() {
el17tc 0:72f372170a73 10 x = 5;
el17tc 0:72f372170a73 11 y = 32;
el17tc 0:72f372170a73 12 }
el17tc 0:72f372170a73 13 void virtual run() {
el17tc 0:72f372170a73 14 printf("YesButton pushed\n");
el17tc 0:72f372170a73 15 restartFlag = true;
el17tc 0:72f372170a73 16 }
el17tc 0:72f372170a73 17 };
el17tc 0:72f372170a73 18 // no button used in the VictoryMenu and the DefeatMenu
el17tc 0:72f372170a73 19 class NoButton : public Button {
el17tc 0:72f372170a73 20 public:
el17tc 0:72f372170a73 21 NoButton() {
el17tc 0:72f372170a73 22 x = 58;
el17tc 0:72f372170a73 23 y = 32;
el17tc 0:72f372170a73 24 }
el17tc 0:72f372170a73 25 void virtual run() {
el17tc 0:72f372170a73 26 printf("NoButton pushed\n");
el17tc 0:72f372170a73 27 menuFlag = true;
el17tc 0:72f372170a73 28 }
el17tc 0:72f372170a73 29 };
el17tc 0:72f372170a73 30 // VictoryMenu displays when the player escapes the maze, it displays score
el17tc 0:72f372170a73 31 // and restart options
el17tc 0:72f372170a73 32 class VictoryMenu : public Menu {
el17tc 0:72f372170a73 33 public:
el17tc 0:72f372170a73 34 VictoryMenu(N5110* screenPtr) : Menu(screenPtr) {
el17tc 0:72f372170a73 35 buttons[0] = new YesButton;
el17tc 0:72f372170a73 36 buttons[1] = new NoButton;
el17tc 0:72f372170a73 37 currentButton = buttons[0];
el17tc 0:72f372170a73 38 numOfButtons = 2;
el17tc 0:72f372170a73 39 buttonIndex = 0;
el17tc 0:72f372170a73 40 }
el17tc 0:72f372170a73 41 void virtual draw() {
el17tc 0:72f372170a73 42 std::stringstream sscore;
el17tc 0:72f372170a73 43 sscore << "Score: " << score;
el17tc 0:72f372170a73 44 lcd->printString("VICTORY",10,1);
el17tc 0:72f372170a73 45 lcd->printString(sscore.str().c_str(),10,2);
el17tc 0:72f372170a73 46 lcd->printString("Play again?",10,3);
el17tc 0:72f372170a73 47 lcd->printString("Yes No",10,4);
el17tc 0:72f372170a73 48 }
el17tc 0:72f372170a73 49 ~VictoryMenu() {
el17tc 0:72f372170a73 50 delete buttons[0];
el17tc 0:72f372170a73 51 delete buttons[1];
el17tc 0:72f372170a73 52 }
el17tc 0:72f372170a73 53 };
el17tc 0:72f372170a73 54
el17tc 0:72f372170a73 55 #endif // VICTORYMENU_H