JianWei Lee
/
project_game
Meteor defense project
Diff: GameEngine/GameEngine.cpp
- Revision:
- 32:580d74825810
- Parent:
- 31:1c0e47931e84
- Child:
- 34:6ac9541d4c31
--- a/GameEngine/GameEngine.cpp Wed Apr 19 21:42:46 2017 +0000 +++ b/GameEngine/GameEngine.cpp Fri Apr 21 12:00:17 2017 +0000 @@ -9,11 +9,24 @@ { } -void GameEngine::init() { +void GameEngine::startingMenu(Gamepad &pad, N5110 &lcd) { + _gui.startingMenu(lcd); + ledNumber ++; + pad.led(ledNumber, 1.0); + pad.led(ledNumber - 1, 0.0); + if (ledNumber == 6) { + ledNumber = 0; + } else { + pad.led(6, 0.0); + } + _gui.preventDoubleClick(pad); + +} +void GameEngine::init(int w) { _d1.droneInit(20, 46, 0, 42); //drone1 is taking left side pixel 0 to 42. _d2.droneInit(62, 46, 42, 84); //drone2 is taking right side pixel 42 to 83; weap.init(); - spa.init(); + spa.init(w); //printf("init completed \n"); } void GameEngine::update(Gamepad &pad, N5110 &lcd) { @@ -22,6 +35,7 @@ drawSpawn(lcd); drawLaserPlayer(pad, lcd); bombAndShield(pad, lcd); + checkGameRule(pad, lcd); } void GameEngine::weapUpgrade(Gamepad &pad, N5110 &lcd) { if (pad.check_event(Gamepad::START_PRESSED)) { @@ -43,7 +57,7 @@ wait(0.2); lcd.clear(); } - done = 1; + doneUpgrade = 1; //remember to re-initialise everything after a wave. } } @@ -61,7 +75,6 @@ //printf("moving spawn b \n"); } spa.updateSpawn(Array, Array2, charArray, charArray2, lcd); - //checkGameRule(lcd); } void GameEngine::drawLaserPlayer(Gamepad &pad, N5110 &lcd) { weap.drawPlayer(pad, lcd); @@ -72,15 +85,18 @@ weap.drawLaser(Array2, charArray2, lcd); } } -void GameEngine::checkGameRule(N5110 &lcd) { +void GameEngine::checkGameRule(Gamepad &pad, N5110 &lcd) { //the only way to lose is when the spawn reaches y = 46. for ( int x = 0; x < 84; x ++) { if (Array[x][46] > 0) { while (1) { lcd.clear(); lcd.printString("Game Over",10,3); - lcd.refresh(); - wait(1.0); + lcd.refresh(); + pad.leds_on(); + wait(0.1); + pad.leds_off(); + wait(0.1); } } }