ELEC2645 (2018/19) / Mbed 2 deprecated el17aio

Dependencies:   mbed

Revision:
31:c7bd3ed16840
Parent:
26:a53d41adf40b
Child:
42:ee13e1d103d8
Child:
43:500b8cff3715
--- a/Ship/Ship.cpp	Fri Apr 19 19:40:01 2019 +0000
+++ b/Ship/Ship.cpp	Sat Apr 20 03:52:22 2019 +0000
@@ -74,6 +74,7 @@
 
 void Ship::update_ship(float x_joystick,float y_joystick)
 {
+    int border = 1;
     // Only change position if joystick is reasonably moved
     if(-0.25 > x_joystick || x_joystick > 0.25 || -0.25 > y_joystick || y_joystick > 0.25) {
         // Update positions using joystick and the intended ships speed
@@ -81,17 +82,17 @@
         _ship_ypos = _ship_ypos - (y_joystick*_ship_speed);
 
         // Dont let sprite move out of screen
-        if(_ship_xpos < 0) {
-            _ship_xpos = 0;
+        if(_ship_xpos < border) {
+            _ship_xpos = border;
         }
-        if(_ship_xpos > (84 - (_ship_width))) {
-            _ship_xpos = 84 - _ship_width;
+        if(_ship_xpos > (84 - (_ship_width)- 7)) {
+            _ship_xpos = 84 - _ship_width - 7;
         }
-        if(_ship_ypos < 0) {
-            _ship_ypos = 0;
+        if(_ship_ypos < border) {
+            _ship_ypos = border;
         }
-        if(_ship_ypos > (48 - (_ship_height))) {
-            _ship_ypos = 48 - _ship_height;
+        if(_ship_ypos > (48 - (_ship_height) - border)) {
+            _ship_ypos = 48 - _ship_height - border;
         }
     }
     // printf("y_joysticzk = %f\n",y_joystick);