Mochu Yao explorer game

Dependencies:   mbed

Revision:
33:ea83f08fa466
Parent:
32:47d98959b4ef
Child:
34:66e37a0d59c3
--- a/Gameengine/Gameengine.cpp	Wed Apr 29 12:19:12 2020 +0000
+++ b/Gameengine/Gameengine.cpp	Wed Apr 29 13:28:41 2020 +0000
@@ -30,13 +30,14 @@
     if(_player.get_reset_flag()) {
           gamepad.leds_on();
           lcd.clear();
+      for (int i = 0; i < 80; i++) {
       lcd.printString("Try Again",0,2);
       lcd.printString("Score:",0,4);  
       lcd.refresh();
       // dependent on counters.
       wait(0.001);  // Control speed of the sequence.
       sprintf(buffer,"%2d",_player_score); 
-      lcd.printString(buffer,15,4);
+      lcd.printString(buffer,15,4); }
       reset_game_engine();
        }
       }
@@ -65,11 +66,13 @@
           _f_flag = true; }
     else if (((set_line_3.right < _player_x) && (_player_x < (set_line_3.left - 5))) && _player_y == 20) {
           _f_flag = true; }
+    else if ((_player_x <= 0) && (_player_x >= 80)) {
+          _f_flag = true; }
           }
           
 void Gameengine::check_collision(Gamepad &gamepad) {
-    if ((_player_x == _item.get_item_x())
-      && (_player_y == _item.get_item_y() - 8)) {  
+    if ((_player_x == _item.get_item_x()-3)
+      && (_player_y == _item.get_item_y() - 5)) {  
     _collision_flag = true;
     _player_score++;
     _item.set_item(((rand()%80)+ 5) , ((rand()%80)+ 5));  // use the rand()%m function to generate a number from 80 to 1