ELEC2645 (2018/19) / Mbed 2 deprecated EL17MCD

Dependencies:   mbed

Revision:
10:d4fb12e9e7cd
Parent:
9:fe912235dd71
Child:
11:4e2eb64031a0
--- a/main.cpp	Wed Apr 10 14:27:37 2019 +0000
+++ b/main.cpp	Fri Apr 12 12:01:47 2019 +0000
@@ -18,6 +18,8 @@
 #define PI 3.14159265
 #define DEG2PI 0.0174532925 
 
+#include <cmath>
+
 #ifdef WITH_TESTING
 
 #endif
@@ -43,50 +45,36 @@
 int main()
 {
     lcd.init();
-    proj.set_launch_parameters(0, 4, 6, 45, 1.3, 0.02, 0.01);
 
-    //tankl.set_health(1);
+    float a;
+    float p;
+    
+    int i = 0;
+    tankl.set_angle(0);
+    tankl.set_speed(4);
+    tankl.set_position(40-6, 0);
+
+
    // welcome();  // display welcome message 
 
     while(1) {  // infinite loop
             
-        proj.update_flight();
         lcd.clear();
-        proj.draw(lcd);
+        tankl.draw(lcd);
         lcd.refresh();
-        wait_ms(50);
-        if (proj.check_boundaries() == true) {break;}   
+        wait_ms(16.666);
+        
+        a = 50 + 50 * sin((double)i/50);
+        p = 1.1*cos((double)i / 60);
+        
+        tankl.set_angle(a);       
+        tankl.move_position(p);     
+  
+        i++;
+        
     }
 lcd.clear();
 lcd.printString("DONE",0,1);
 lcd.refresh();
 wait(10);
 }    
-/*        srand(time(NULL));  
-        int t_pos_x = rand() % (84-1-10); // Tank position
-        int t_pos_y = rand() % (48-1-6);
-        tankl.set_position(t_pos_x, t_pos_y);
-        
-        int p_pos_x = rand() % (84-1-5);  // projectile position
-        int p_pos_y = rand() % (48-1-5);
-        proj.set_position(p_pos_x, p_pos_y);
-        
-        tankl.generate_hitbox();
-        proj.generate_hitbox();
-        bool hit = engine.collision_pl(tankl, proj);   
-        
-        lcd.clear();
-        tankl.draw(lcd);
-        proj.draw(lcd);
-        lcd.refresh(); 
-        if (hit == true) {
-            wait(1.5);
-            lcd.clear();
-            tankl.lose_health();
-            lcd.printString("DONE",0,1);
-            lcd.refresh();
-            wait(0.5);
-        }
-        else {wait_ms(50);}
-    }
-*/
\ No newline at end of file