ECE 2036 Project

Dependencies:   mbed wave_player 4DGL-uLCD-SE

Revision:
2:2042f29de6b7
Parent:
0:cf4396614a79
--- a/physics.cpp	Wed Nov 08 21:01:43 2017 +0000
+++ b/physics.cpp	Thu Nov 21 16:10:57 2019 +0000
@@ -2,17 +2,23 @@
 #include "math_extra.h"
 
 void forward_euler(Physics* state, float delta)
-{ 
+{
     // TODO: Implement proper forward euler updates for position and velocity
-  
+
     // Compute random motion
-    float damp = 0.5;
-    float dx = damp*coin_flip();
-    float dy = damp*coin_flip();
+//    float damp = 0.5;
+//    float dx = damp*coin_flip();
+//    float dy = damp*coin_flip();
+
+//    state->px = state->px + dx;
+//    state->py = state->py + dy;
+//    state->vx = dx;
+//    state->vy = dy;
 
     // Update position and velocity
-    state->px = state->px + dx;
-    state->py = state->py + dy;
-    state->vx = dx;
-    state->vy = dy;
+    state->vx += state->ax * delta;
+    state->vy += state->ay * delta;
+    state->px += state->vx * delta;
+    state->py += state->vy * delta;
+
 }
\ No newline at end of file