ELEC2645 (2018/19) / Mbed 2 deprecated el17set_

Dependencies:   mbed

Revision:
18:ba4159ab4da7
Parent:
16:37d98c281eb3
Child:
21:7d4827af00d6
--- a/Enemy/Enemy1.cpp	Wed May 08 13:03:24 2019 +0000
+++ b/Enemy/Enemy1.cpp	Wed May 08 15:01:45 2019 +0000
@@ -28,20 +28,12 @@
 
 void Enemy1::movement(N5110 &lcd){
     accel = 1;
-    for (int i = 0; i < 60; i++) {
-        if (y_enem == 17 && x_enem < 50){
-            x_enem += accel;
-        }
-        if (y_enem < 24 && x_enem == 50){
-            y_enem += accel;
-        }
-        if (y_enem == 24 && x_enem > 27){
-            x_enem -= accel;
-        }
-        if (y_enem > 17 && x_enem == 27){
-            y_enem -= accel;
-        }
-    }
+    _incrementer_enem1++;
+    if ( _incrementer_enem1 == 62 ) { _incrementer_enem1 = 0; }
+    if ( _incrementer_enem1 >= 0 && _incrementer_enem1 <= 23) { x_enem++; }
+    else if ( _incrementer_enem1 >= 24 && _incrementer_enem1 <= 30) { y_enem++; }
+    else if ( _incrementer_enem1 >= 31 && _incrementer_enem1 <= 54) { x_enem--; }
+    else if ( _incrementer_enem1 >= 55 && _incrementer_enem1 <= 61) { y_enem--; }
 }
 
 bool Enemy1::northCollision(int x, int y, N5110 &lcd){