ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_ll17lrc_v2

Dependencies:   mbed

Revision:
2:823dea76ff2e
Child:
3:4494e6928194
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Imposs/ImpossEngine.cpp	Sat May 16 13:06:29 2020 +0000
@@ -0,0 +1,108 @@
+#include "ImpossEngine.h"
+#include "Zero.h"
+
+ImpossEngine::ImpossEngine()
+{
+
+}
+
+ImpossEngine::~ImpossEngine()
+{
+
+}
+
+void PongEngine::read_input(Gamepad &pad)
+{
+    _d = pad.get_direction();
+    _mag = pad.get_mag();
+}
+
+void ImpossEngine::draw(N5110 &lcd)
+{
+    // draw the elements in the LCD buffer
+    // pitch
+    
+    _ball.draw(lcd);
+    
+    if (level == 0){
+        zero.draw(lcd);
+    }
+
+    if (level == 1){
+        one.draw(lcd);
+    }
+    
+    if
+
+}
+
+void ImpossEngine::update(Gamepad &pad)
+{
+    _ball.update(_d);
+
+    check_collision(pad);
+    
+    check_finish(pad);
+}
+
+void ImpossEngine::check_collision(Gamepad &pad)
+{
+    int _x = 0;
+    int _y = 0;
+    bool collision = false;
+    //check around ball to see if it has made contact with anything
+    
+    while(i = 0;i < 4;i++){
+        
+        if(lcd.getPixel(ball_x_pos + _x,ball_y_pos + _y) == 1){
+            collision = true;
+            }
+            
+        _x ++;
+        
+    }
+    
+    while(i = 0;i < 4;i++){
+        
+        if(lcd.getPixel(ball_x_pos + _x,ball_y_pos + _y) == 1){
+            collision = true;
+            }
+            
+        _y ++;
+        
+    }
+    
+    while(i = 0;i < 4;i++){
+        
+        if(lcd.getPixel(ball_x_pos + _x,ball_y_pos + _y) == 1){
+            collision = true;
+            }
+            
+        _x --;
+        
+    }
+    
+    while(i = 0;i < 4;i++){
+        
+        if(lcd.getPixel(ball_x_pos + _x,ball_y_pos + _y) == 1){
+            collision = true;
+            }
+            
+        _y --;
+        
+    if(collision == true){
+        ball_x_pos = 0;
+        ball_y_pos = 21;
+        }
+    }
+    
+void ImpossEngine::check_finish(Gamepad &pad)
+{
+    
+    if(ball_x_pos == 82){
+        level ++;
+        ball_x_pos = 0;
+        ball_y_pos = 21;
+        }
+        
+}
\ No newline at end of file