ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_ll17lrc_v2

Dependencies:   mbed

Revision:
7:35465b3bf586
Parent:
5:5c132202b642
Child:
8:10eb578dd754
diff -r 312b7ae0c0f2 -r 35465b3bf586 Imposs/ImpossEngine.cpp
--- a/Imposs/ImpossEngine.cpp	Sun May 17 19:12:52 2020 +0000
+++ b/Imposs/ImpossEngine.cpp	Mon May 18 14:28:05 2020 +0000
@@ -15,7 +15,10 @@
 
 void ImpossEngine::complete(Gamepad &pad,N5110 &lcd)
 {
-    _start.complete(pad,lcd);   
+    _start.complete(pad,lcd); 
+    int x = 0;
+    int y = 21;
+    _ball.init(x,y);
 }
  
 void ImpossEngine::read_input(Gamepad &pad)
@@ -29,25 +32,27 @@
     // draw the elements in the LCD buffer
     // pitch   
     
+    
     if (level == 0){
         _zero.draw(lcd);
     }
 
     if (level == 1){
         _one.draw(lcd);
-    }
+    } 
+    
+     _ball.update(_d);
     
     _ball.draw(lcd);
 
 }
 
-void ImpossEngine::update(Gamepad &pad,N5110 &lcd,int level)
+void ImpossEngine::update(Gamepad &pad,N5110 &lcd)
 {
-    _ball.update(_d);
 
     check_collision(pad,lcd);
     
-    check_finish(level);
+    check_finish();
 }
 
 void ImpossEngine::set_level_zero(){
@@ -63,8 +68,8 @@
     int _x = 0;
     int _y = 0;
     int i = 0;
-    int x_pos = _ball.get_ball_x_pos();
-    int y_pos = _ball.get_ball_y_pos();
+    int x_pos = _ball.get_ball_x_pos() - 1;
+    int y_pos = _ball.get_ball_y_pos() - 1;
     bool collision = false;
     //check around ball to see if it has made contact with anything
     
@@ -126,12 +131,12 @@
     }
 }
 
-void ImpossEngine::check_finish(int level)
+void ImpossEngine::check_finish()
 {
     
-    int x_pos = _ball.get_ball_x_pos();
+    int pos = _ball.get_ball_x_pos();
     
-    if(x_pos == 82){
+    if(pos == 82){
         level++;
         _ball.level_finish();
         }