Yufan Zhong / Mbed 2 deprecated GOLD_MINER

Dependencies:   mbed

Revision:
5:58932f73fc35
Parent:
4:71d01af424c1
Child:
6:3381131afe50
--- a/MinerEngine/MinerEngine.cpp	Sat Apr 25 08:55:23 2020 +0000
+++ b/MinerEngine/MinerEngine.cpp	Sat Apr 25 10:29:42 2020 +0000
@@ -358,7 +358,29 @@
         loading(pad,lcd);     
 }
   
-  
+void MinerEngine::game_over(Gamepad &pad, N5110 &lcd) {
+    
+    while ( pad.check_event(Gamepad::START_PRESSED) == false 
+    && pad.check_event(Gamepad::JOY_PRESSED) == false 
+    && pad.check_event(Gamepad::BACK_PRESSED) == false) 
+    {
+      lcd.drawRect(0,0,WIDTH,HEIGHT,FILL_TRANSPARENT);
+      lcd.drawRect(1,1,WIDTH-2,HEIGHT-2,FILL_TRANSPARENT);
+      lcd.printString(" !! Game Over !! ",2,2);
+      lcd.printString(" Press [back] to menu",4,3);
+      lcd.printString(" press [start] to restart",4,4);
+      }
+      
+      if (pad.check_event(Gamepad::START_PRESSED) == true
+         ||pad.check_event(Gamepad::JOY_PRESSED) == true) {
+            state=3;
+      }
+      
+      if (pad.check_event(Gamepad::BACK_PRESSED) == true) {
+            state=0;
+      }
+}
+
 void MinerEngine::play_music(Gamepad &pad) {
         pad.tone(370,0.15); 
         wait(0.35);
@@ -453,25 +475,3 @@
          _gold.init(9);
          }
 }
-// check claw next
-    /*
-    Vector2D claw_pos = _claw.get_pos();
-
-    // see if claw has hit the winch by checking for overlaps
-    if (
-        (claw_pos.y >= claw_pos.y) && //top
-        (claw_pos.y <= claw_pos.y + _winch_height) && //bottom
-        (claw_pos.x + _claw_size >= _claw_x) && //left
-        (claw_pos.x + _claw_size <= _claw_x + _winch_width)  //right
-    ) {
-        // if it has, fix position and reflect x velocity
-        claw_pos.x = _claw_x - _claw_size;
-        claw_velocity.x = -claw_velocity.x;
-        // audio feedback
-        pad.tone(1000.0,0.1);
-    }
-
-    // write new attributes
-    _claw.set_velocity(claw_velocity);
-    _claw.set_pos(claw_pos);
-    */
\ No newline at end of file