Ben Evans / Mbed 2 deprecated Defender_Game

Dependencies:   mbed

Revision:
34:85ccc16f24d2
Parent:
28:a5958497d5ce
--- a/RandomMovement/RandomMovement.cpp	Thu May 14 22:41:16 2020 +0000
+++ b/RandomMovement/RandomMovement.cpp	Fri May 15 12:05:33 2020 +0000
@@ -8,6 +8,7 @@
     case 3: set_sprite_direction(-1, 0); break;
     case 4: set_sprite_direction(-1, 1); break;
     case 5: set_sprite_direction(-1, -1); break;
+    case 6: set_sprite_direction(0, -1); break;
     }
 }
 
@@ -25,4 +26,16 @@
         //printf("\random_direction_ =  %d\n", random_direction_);
     }    
     random_move_counter_ = rand() % 10 + 20;
-}
\ No newline at end of file
+}
+
+int RandomMovement::calc_sprite_movement(Direction d_){  
+    // moves the people in oposite direction to spaceship when it's position is 
+    // at min and max x positions and joystick has direction     
+    if (d_ == W || d_ == NW || d_ == SW){ 
+        return 2;
+    }else if (d_ == E || d_ == NE || d_ == SE){ 
+        return -2; 
+    }else {
+        return 0;
+    }
+}  
\ No newline at end of file