Project Submission (late)
Dependencies: mbed
Diff: Menus/StartMenu.h
- Revision:
- 0:72f372170a73
- Child:
- 3:83e79d31930c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Menus/StartMenu.h Fri May 10 08:07:10 2019 +0000 @@ -0,0 +1,83 @@ +#ifndef STARTMENU_H +#define STARTMENU_H + +#include "Menus.h" + + +// button which changes the size of the maze +class SizeButton : public Button { + public: + SizeButton() { + x = 5; + y = 16; + } + void virtual run() { + if (mazeSize < 20) + mazeSize += 4; + printf("sizeButton pushed\n"); + } + void virtual runBack() { + if (mazeSize > 12) + mazeSize -= 4; + printf("sizeButton decreasing\n"); + } +}; + +// button which toggles the timer on or off +class TimerButton : public Button { + public: + TimerButton() { + x = 5; + y = 24; + } + void virtual run() { + timerFlag = !timerFlag; + printf("timerButton pushed\n"); + } +}; + +// button that triggers the main game loop +class PlayButton : public Button { + public: + PlayButton() { + x = 5; + y = 40; + } + void virtual run() { + printf("PlayButton pushed\n"); + beginFlag = true; + } +}; + + +// the StartMenu is the menu for game setup and starting the game. +class StartMenu : public Menu { + public: + StartMenu(N5110* screenPtr) : Menu(screenPtr) { + buttons[0] = new SizeButton; + buttons[1] = new TimerButton; + buttons[2] = new PlayButton; + currentButton = buttons[0]; + numOfButtons = 3; + buttonIndex = 0; + } + void virtual draw() { + std::stringstream ssize; + ssize << "Size: " << mazeSize; + std::string someString; + if (timerFlag) + someString = "Timer: YES"; + else + someString = "Timer: NO"; + lcd->printString("Game params:",10,1); + lcd->printString(ssize.str().c_str(),10,2); + lcd->printString(someString.c_str(),10,3); + lcd->printString("Play",10,5); + } + ~StartMenu() { + delete buttons[0]; + delete buttons[1]; + } +}; + +#endif // STARTMENU_H \ No newline at end of file