JianWei Lee
/
project_game
Meteor defense project
Diff: main.cpp
- Revision:
- 44:aa086363d09f
- Parent:
- 42:152e84494ad9
--- a/main.cpp Mon May 01 17:55:38 2017 +0000 +++ b/main.cpp Wed May 03 21:00:43 2017 +0000 @@ -9,13 +9,14 @@ #define Cols 84 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); +AnalogIn brightness(PTB2); Gamepad pad; GameEngine game; int gamefps = 15; Ticker waveCompleteTicker; -int setTicker; +int Start_The_Game_flag; int waveComplete_flag; int waveNumber; int menu; @@ -36,13 +37,14 @@ while (true) { if (game.gameMenu_flag == 1) { gameMenu(); - setTicker = 1; //set the ticker. + Start_The_Game_flag = 1; //set the startgame flag game.gameMenu_flag = 0; //remove flag } - if (setTicker == 1 || game.retry_flag == 1) { + if (Start_The_Game_flag == 1 || game.retry_flag == 1) { game.retry_flag = 0; //clear flag startGame(); } + lcd.setBrightness(brightness); //this is the game game.update(pad, lcd); @@ -75,7 +77,7 @@ game.init(waveNumber); game.update_MainToRetry(); //save the game state at the start of each wave waveCompleteTicker.attach(&waveComplete_isr,60); //60 seconds for a wave. - setTicker = 0; //clear set ticker flag + Start_The_Game_flag = 0; //clear set ticker flag if (pad.check_event(Gamepad::START_PRESSED)) { //printf("start double click prevented"); } @@ -90,7 +92,7 @@ if (game.doneUpgrade_flag == 1) { waveComplete_flag = 0; //get out of while loop - setTicker = 1; //continue the game + Start_The_Game_flag = 1; //continue the game game.doneUpgrade_flag = 0; //printf("i got out"); }