JianWei Lee
/
project_game
Meteor defense project
Diff: GameEngine/GameEngine.cpp
- Revision:
- 41:1b396334256b
- Parent:
- 40:3a0c66a0e10e
- Child:
- 42:152e84494ad9
diff -r 3a0c66a0e10e -r 1b396334256b GameEngine/GameEngine.cpp --- a/GameEngine/GameEngine.cpp Sat Apr 29 19:27:20 2017 +0000 +++ b/GameEngine/GameEngine.cpp Sun Apr 30 21:53:28 2017 +0000 @@ -38,6 +38,7 @@ laser_and_cannon(pad, lcd); bomb_And_Shield(pad, lcd); checkGameRule(pad, lcd); + //_gui.preventDoubleClick(pad); } void GameEngine::weapUpgrade(Gamepad &pad, N5110 &lcd) { if (pad.check_event(Gamepad::START_PRESSED)) { @@ -95,7 +96,7 @@ weap.laser_Main(scnd.Arr, scnd.cArr, lcd); //cannon can only be fired when the laser is switched on. - if ( weap._cannon > 320) { //when sufficient cost, check for button Y. + if ( weap._cannon > 320) { //when sufficient, check for button Y. if ( pad.check_event(Gamepad::Y_PRESSED)) { //press button to set flag (fire the cannon) fireInTheHole_flag = 1; } @@ -114,6 +115,7 @@ for ( int x = 0; x < 84; x ++) { if (main.Arr[x][46] > 0) { //if anything reaches line y=46 NumberOfLife --; + pad.tone(750.0,0.5); //printf("opps you lost a life. NumberOfLife = %d \n",NumberOfLife); if (NumberOfLife == 0) { gameOver(pad, lcd); @@ -125,7 +127,7 @@ while (retry_flag == 0 && gameMenu_flag == 0) { //while both are 0 lcd.clear(); lcd.printString("Game Over",10,3); - lcd.printString("GivUp Retry",0,5); + lcd.printString("GivUp Retry",0,5); lcd.refresh(); pad.leds_on(); wait(0.1); @@ -179,7 +181,7 @@ printf("shield double click prevented"); } } -void GameEngine::updateArray() { //clean up tool +void GameEngine::updateArray() { //update main array with secondary array and clean up the array for (int x = 0; x < Cols; x++) { for (int y = 0; y < Rows; y++) { main.Arr[x][y] = scnd.Arr[x][y]; @@ -188,7 +190,7 @@ } } } -void GameEngine::update_MainToRetry() { +void GameEngine::update_MainToRetry() { //update Retry array with main array for (int x = 0; x < Cols; x ++) { for (int y = 0; y < Rows; y ++) { retry.Arr[x][y] = main.Arr[x][y]; @@ -197,7 +199,7 @@ } printf("main to retry array updated \n"); } -void GameEngine::update_RetryToMain() { +void GameEngine::update_RetryToMain() {//update main & secondary array with Retry array for (int x = 0; x < Cols; x ++) { for (int y = 0; y < Rows; y ++) { main.Arr[x][y] = retry.Arr[x][y]; @@ -207,4 +209,15 @@ } } printf("retry to main array updated \n"); +} +void GameEngine::reset_Game() { //clear everything - arrays and weapon + for (int x = 0; x < Cols; x ++) { + for (int y = 0; y < Rows; y ++) { + main.Arr[x][y] = 0; + main.cArr[x][y] = '\0'; + scnd.Arr[x][y] = 0; + scnd.cArr[x][y] = '\0'; + } + } + weap.reset_WeaponVariables(); } \ No newline at end of file