ELEC2645 (2018/19) / Mbed 2 deprecated EL17MCD

Dependencies:   mbed

Revision:
8:d4e419dad90f
Parent:
7:a3ccabdebe2e
Child:
9:fe912235dd71
--- a/main.cpp	Tue Apr 09 17:09:29 2019 +0000
+++ b/main.cpp	Wed Apr 10 11:33:10 2019 +0000
@@ -15,6 +15,8 @@
 #include "TankL.h"
 #include "TanksEngine.h"
 #include "Projectile.h"
+#define PI 3.14159265
+#define DEG2PI 0.0174532925 
 
 #ifdef WITH_TESTING
 
@@ -41,12 +43,36 @@
 int main()
 {
     lcd.init();
-    tankl.set_health(1);
+    int p_pos_x = 0;
+    int p_pos_y = 0;
+    int time = 0;
+    float lnch_ang = 70.0; //in degrees
+    float init_vel = 1.3; 
+    float init_x = 0;
+    float init_y = 0;
+    float grav_acc = 0.02;
+    float wind_acc = 0;
+    //tankl.set_health(1);
    // welcome();  // display welcome message 
 
     while(1) {  // infinite loop
-        
-        srand(time(NULL));  
+            
+        p_pos_x = 10 + init_vel * time * cos(lnch_ang * DEG2PI) - 0.5 * wind_acc * time * time;
+        p_pos_y = 6 + init_vel * time * sin(lnch_ang * DEG2PI) - 0.5 * grav_acc * time * time;
+        time++;
+        proj.set_position(p_pos_x, p_pos_y);
+        if (p_pos_x < -3 || p_pos_x > 87  || p_pos_y < -3) {break;}
+        lcd.clear();
+        proj.draw(lcd);
+        lcd.refresh();
+        wait_ms(50);    
+    }
+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);
@@ -67,11 +93,10 @@
             wait(1.5);
             lcd.clear();
             tankl.lose_health();
-            lcd.printString("HIT",0,1);
+            lcd.printString("DONE",0,1);
             lcd.refresh();
             wait(0.5);
         }
         else {wait_ms(50);}
     }
-
-}
\ No newline at end of file
+*/
\ No newline at end of file