Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 60:3df033345059
- Parent:
- 58:4a826093d9e9
- Child:
- 63:ec95e155fb30
--- a/main.cpp Tue May 07 00:38:10 2019 +0000
+++ b/main.cpp Tue May 07 23:51:54 2019 +0000
@@ -15,9 +15,6 @@
#include "Gamepad.h"
#include "Gameengine.h"
-#ifdef WITH_TESTING
-# include "tests.h"
-#endif
/////////////// objects ///////////////
Gameengine game;
@@ -59,7 +56,9 @@
/** Displays options screen
* @details gives player controls and displays credits
*/
- void option_screen();
+void option_screen();
+
+bool options = false;
///////////// functions ////////////////
@@ -90,7 +89,6 @@
lcd.setBrightness(1.0);
pad.init();
game.game_init();
- contrast();
}
// detects which level is being played and draws the level objects with collision settings
@@ -115,24 +113,23 @@
// displays start screen and waits for user to press start
void start_screen()
{
- lcd.drawSprite(2,20,8,3,(int *)miner_right);
- lcd.drawSprite(79,20,8,3,(int *)miner_left);
- lcd.drawRect(0,0,84,48, FILL_TRANSPARENT);
- lcd.printString("MANIC MILNER",7,1);
- lcd.printString("Press start!",8,2);
- lcd.printString("A = Options",10,4);
- lcd.refresh();
- while ( pad.check_event(Gamepad::START_PRESSED) == false) {
+ while (pad.check_event(Gamepad::START_PRESSED) == false && options == false) {
+ lcd.clear();
+ lcd.drawSprite(2,20,8,3,(int *)miner_right);
+ lcd.drawSprite(79,20,8,3,(int *)miner_left);
+ lcd.drawRect(0,0,84,48, FILL_TRANSPARENT);
+ lcd.printString("MANIC MILNER",7,1);
+ lcd.printString("Press start!",8,2);
+ lcd.printString("A = Controls",6,4);
+ contrast();
+ //printf("start screen = %d \n",options);
+ if (pad.check_event(Gamepad::A_PRESSED) == true) {
+ options = true;
+ //printf("options = %d \n",options);
+ }
}
}
-void option_screen()
-{
- if (pad.check_event(Gamepad::A_PRESSED) == true)
- lcd.printString("A = Options",10,4);
- lcd.refresh();
-}
-
// displays appropriate screen with final score for game over and game complete
void restart()
{
@@ -142,16 +139,37 @@
lcd.drawRect(0,0,84,48, FILL_TRANSPARENT);
lcd.printString("Game Over! ",14,1);
lcd.printString("Score ",18,2);
- lcd.printString("Play Again?",10,4);
+ lcd.printString("Back = Replay",3,4);
}
if (game.game_complete(lcd) == true) {
lcd.clear();
game.get_score(lcd);
- lcd.drawRect(0,0,84,48, FILL_TRANSPARENT);
lcd.printString("YOU WIN!!! ",12,1);
lcd.printString("Score ",18,2);
lcd.printString("Well done!!!",8,4);
}
+ if(pad.check_event(Gamepad::BACK_PRESSED) == true) {
+ init();
+ }
+}
+
+void option_screen()
+{
+ while (options == true) {
+ lcd.clear();
+ lcd.printString("Stick = L/R",0,0);
+ lcd.printString("A = Jump ",0,1);
+ lcd.printString("Get keys and",0,2);
+ lcd.printString("return to exit",0,3);
+ lcd.printString("Led=time/lives",0,4);
+ lcd.printString("<< Press back",0,5);
+ //printf("options screen = %d \n",options);
+ lcd.refresh();
+ if (pad.check_event(Gamepad::BACK_PRESSED) == true) {
+ options = false;
+ start_screen();
+ }
+ }
}
// leds indicate how many lives and time left