ELEC2645 (2018/19) / Mbed 2 deprecated el17lw

Dependencies:   mbed

Revision:
19:f35887b14c23
Parent:
18:304700b5d8f8
Child:
20:a8cad4e044ea
--- a/Engine/Engine.cpp	Fri Apr 12 11:30:25 2019 +0000
+++ b/Engine/Engine.cpp	Mon Apr 15 18:49:35 2019 +0000
@@ -22,18 +22,26 @@
     reset_engine();
     wait(1);
     lcd.clear();
-    lcd.refresh();
+    for (int i = 0; i < 40; i = i + 8) {
+      for (int j = 0; j < 84; j++) {
+        lcd.setPixel(j,i,true);
+        lcd.setPixel(i,j,true);
+        lcd.printString("TRY AGAIN",30,5);  
+        lcd.refresh();
+        wait(0.001);
+      }  
+    }
     wait(1);
   }
 }
 
 void Engine::reset_skater() {
-  _moving_counter = 0;
-  _jump_counter = 0;
   _skater_direction = Left;
-  _level_condition = 0;
   _start_platform = true;
   _skater.set_reset_flag(false);
+  _moving_counter = 0;
+  _jump_counter = 20;
+  _fall_flag = false;
 }  
 
 void Engine::reset_engine() {
@@ -151,9 +159,9 @@
 void Engine::generate_fire(int game_counter) {
   // Generate the x and y coordinate of the fire. X is from the fire class method and
   // y is claculated from a quadratic expression that oscilates from 5 to 23 with the
-  // game counter going from 0 to 90 periodicly as its input.
+  // game counter going from 0 to 99 periodicly as its input.
   _fire.update_fire();
-  _fire_y = int(float(-0.0089*game_counter*game_counter) + (0.8*game_counter) + 5); 
+  _fire_y = int(-0.0073*game_counter*game_counter + 0.73*game_counter + 5); 
 }
 
 void Engine::update_lcd(N5110 &lcd){
@@ -190,7 +198,7 @@
 void Engine::check_fire_collision() {
   // If the skaters coord match the fire and he is not ducking, the player has died
   // and the game is reset. Game will also reset if skater goes off the screen.
-  if (_input.coord.y > -0.1 && _skater_x == _fire.get_fire_x() && _fire_y - 1 < _skater_y < _fire_y + 1) {
+  if (_input.coord.y > -0.1 && _skater_x == _fire.get_fire_x() && _skater_y > _fire_y - 10 && _skater_y < _fire_y + 10) {
     _skater.set_reset_flag(true);
   } else if ( _skater_x < -10 || _skater_x > 84 ) {
     _skater.set_reset_flag(true);