ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_ll17lrc_v2

Dependencies:   mbed

Revision:
3:4494e6928194
Parent:
2:823dea76ff2e
Child:
4:a9d5fca3b7ba
--- a/Imposs/ImpossEngine.cpp	Sat May 16 13:06:29 2020 +0000
+++ b/Imposs/ImpossEngine.cpp	Sat May 16 15:51:02 2020 +0000
@@ -1,5 +1,11 @@
 #include "ImpossEngine.h"
 #include "Zero.h"
+#include "One.h"
+#include "mbed.h"
+#include "N5110.h"
+#include "Gamepad.h"
+#include "Ball.h"
+#include "StartMenu.h"
 
 ImpossEngine::ImpossEngine()
 {
@@ -11,7 +17,12 @@
 
 }
 
-void PongEngine::read_input(Gamepad &pad)
+void ImpossEngine::complete(Gamepad &pad,N5110 &lcd,int level)
+{
+    _start.complete(pad,lcd,level);   
+}
+
+void ImpossEngine::read_input(Gamepad &pad)
 {
     _d = pad.get_direction();
     _mag = pad.get_mag();
@@ -25,34 +36,36 @@
     _ball.draw(lcd);
     
     if (level == 0){
-        zero.draw(lcd);
+        _zero.draw(lcd);
     }
 
     if (level == 1){
-        one.draw(lcd);
+        _one.draw(lcd);
     }
     
-    if
 
 }
 
-void ImpossEngine::update(Gamepad &pad)
+void ImpossEngine::update(Gamepad &pad,N5110 &lcd, int ball_x_pos, int ball_y_pos)
 {
     _ball.update(_d);
 
-    check_collision(pad);
+    check_collision(pad,lcd,ball_x_pos,ball_y_pos);
     
-    check_finish(pad);
+    check_finish(pad,ball_x_pos,ball_y_pos,level);
 }
 
-void ImpossEngine::check_collision(Gamepad &pad)
+void check_collision(Gamepad &pad,N5110 &lcd, int ball_x_pos, int ball_y_pos)
 {
     int _x = 0;
     int _y = 0;
+    int i = 0;
     bool collision = false;
     //check around ball to see if it has made contact with anything
     
-    while(i = 0;i < 4;i++){
+    while(i < 4){
+        
+        i++;
         
         if(lcd.getPixel(ball_x_pos + _x,ball_y_pos + _y) == 1){
             collision = true;
@@ -62,7 +75,11 @@
         
     }
     
-    while(i = 0;i < 4;i++){
+    i = 0;
+     
+    while(i < 4){
+        
+        i++;
         
         if(lcd.getPixel(ball_x_pos + _x,ball_y_pos + _y) == 1){
             collision = true;
@@ -72,7 +89,11 @@
         
     }
     
-    while(i = 0;i < 4;i++){
+    i = 0;
+    
+    while(i < 4){
+        
+        i++;
         
         if(lcd.getPixel(ball_x_pos + _x,ball_y_pos + _y) == 1){
             collision = true;
@@ -82,7 +103,11 @@
         
     }
     
-    while(i = 0;i < 4;i++){
+    i = 0;
+    
+    while(i < 4){
+        
+        i++;
         
         if(lcd.getPixel(ball_x_pos + _x,ball_y_pos + _y) == 1){
             collision = true;
@@ -95,14 +120,16 @@
         ball_y_pos = 21;
         }
     }
-    
-void ImpossEngine::check_finish(Gamepad &pad)
+}
+
+void check_finish(Gamepad &pad, int ball_x_pos, int ball_y_pos, int level)
 {
     
     if(ball_x_pos == 82){
-        level ++;
+        level++;
         ball_x_pos = 0;
         ball_y_pos = 21;
         }
         
-}
\ No newline at end of file
+}
+