James Cummins / Mbed 2 deprecated el17jnc

Dependencies:   mbed

Revision:
14:108052b6222b
Parent:
13:e5a36fbd48ae
Child:
15:1564bd6b713d
--- a/Ball/Ball.cpp	Fri Apr 12 17:01:47 2019 +0000
+++ b/Ball/Ball.cpp	Sun Apr 14 16:40:51 2019 +0000
@@ -20,11 +20,11 @@
 void Ball::update(FXOS8700CQ &accelerometer){
     int RADIUS = get_radius();
     Data values = accelerometer.get_values();
-    _velocity.x = -5*values.ay;
-    _velocity.y = -5*values.ax;
+    _velocity.x = -5*values.ay;         //axes of the accelerometer are different to orientation of the screen
+    _velocity.y = -5*values.ax;         //negative to account for reversed direction
     _x += _velocity.x;
     _y += _velocity.y;
-    if (_x < RADIUS){ _x = RADIUS;}
+    if (_x < RADIUS){ _x = RADIUS;}     //check wall collisions
     if (_x > 84 - RADIUS){ _x = 83 - RADIUS;}
     if (_y < RADIUS){ _y = RADIUS;}
     if (_y > 48 - RADIUS){ _y = 47 - RADIUS;}