ELEC2645 (2018/19) / Mbed 2 deprecated el17szs

Dependencies:   mbed

Revision:
3:bd3465a70a5a
Parent:
2:e9ac69c17a75
Child:
4:55a0509c4874
diff -r e9ac69c17a75 -r bd3465a70a5a main.cpp
--- a/main.cpp	Sat Apr 06 10:02:52 2019 +0000
+++ b/main.cpp	Mon Apr 15 13:40:49 2019 +0000
@@ -11,32 +11,52 @@
 #include "mbed.h"
 #include "Gamepad.h"
 #include "N5110.h"
+#include "Ball.h"
+
 
 
 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
 Gamepad pad;
+Ball ball;
+
 
 void init();
 
 void welcome();
-void field();
+void draw();
+void ball_test();
 
 int main(){
     int fps=8;
     init();
     welcome();
-    field();
-    wait(1.0f/fps);
+    draw();
+    /*
+    while (1){
+        draw();
+        wait(1.0f/fps);
+    }
+    */
+    while(1){
+        ball.start(lcd);
+        draw();
+        wait(1.0f/fps);
+    }
+    
+    
+    
 }
 void init(){
     lcd.init();
     pad.init();
+    //field.init();
     
     
     lcd.setContrast(0.4);
     lcd.normalMode();      // normal colour mode
     lcd.setBrightness(0.5);
     lcd.clear();
+    ball.init(2,3);
     
 }
 void welcome() {
@@ -56,9 +76,20 @@
     }
  
 }
-void field(){
+void draw(){
     lcd.clear();
-    lcd.drawCircle((WIDTH/2),HEIGHT/2,20,FILL_TRANSPARENT);
-    lcd.drawRect(37,11,12,25,FILL_TRANSPARENT);  
+    lcd.drawCircle((WIDTH/2),HEIGHT/2,23,FILL_TRANSPARENT);
+    lcd.drawRect(37,11,12,30,FILL_TRANSPARENT);
+    ball.draw(lcd);
+    ball.set_field(lcd);
     lcd.refresh();
+}
+void ball_test(){
+    Vector2D ball_pos = ball.get_pos();
+    Vector2D ball_velocity = ball.get_velocity();
+    ball.update();  
+    
+    ball.set_velocity(ball_velocity);
+    ball.set_pos(ball_pos);
+    ball.update(); 
 }
\ No newline at end of file