The library for the game engine
Revision 9:bd53c6e90213, committed 2017-05-04
- Comitter:
- JasonGuo
- Date:
- Thu May 04 11:48:40 2017 +0000
- Parent:
- 8:661097776006
- Commit message:
- sound added
Changed in this revision
GameEngine.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 661097776006 -r bd53c6e90213 GameEngine.cpp --- a/GameEngine.cpp Thu May 04 03:00:54 2017 +0000 +++ b/GameEngine.cpp Thu May 04 11:48:40 2017 +0000 @@ -2,7 +2,7 @@ //funtion to construct GameEngine::GameEngine() { - + } //function to destruct @@ -15,7 +15,7 @@ void GameEngine::init() { monster_number = 50; // monster number is set to 50 - life = 3; // 3 chances to miss the monster + life = 5; // 3 chances to miss the monster _A = 0; // A button check _Jet.init(); // initialise the jet @@ -100,7 +100,7 @@ //printf("Jet_x=%f,Jet_y=%f\n",Jet_pos.x,Jet_pos.y); //printf("M_x=%f,M_y=%f\n",Monster_pos.x, Monster_pos.y); - // game over when the monster hits the jet + // reset jet when the monster hits the jet if( (Jet_pos.x+13 > Monster_pos.x)&& // right (Jet_pos.x < Monster_pos.x+10)&& // left @@ -108,6 +108,8 @@ (Jet_pos.y < Monster_pos.y+10)) // bottom { life -= 1; + pad.tone(1500.0,0.2); + _Jet.init(); _Monster.init(); } } @@ -127,7 +129,6 @@ (_A ==1)) { pad.tone(100.0,0.2); - pad.leds_off(); _A = 0; //Ammo disappears after hit the monster monster_number -= 1; _Monster.init(); @@ -154,7 +155,7 @@ { Monster_pos.y = 0; // top Monster_velocity.y = -Monster_velocity.y; - pad.tone(500.0,0.2); + pad.tone(500.0,0.2); } else if(Monster_pos.y >= HEIGHT - 8) {