Ben Evans University Second Year Project. Game Called Defender.

Dependencies:   mbed

https://os.mbed.com/media/uploads/evanso/84bc1a30759fd6a1e3f1fd1fae3e97c2.png

Hello, soldier, you have been specially selected as the defender of planet earth.

Your mission, if you choose to accept it. Fly around the planet and pulverise invading alien ships for as long as you can. Stop the aliens abducting the innocent people on the ground. Be warned if an alien ship manages to abduct a person and take them to top of the screen, they will no longer move randomly and will begin to hunt you down. This sounds like a challenge you were trained for.

But don’t worry soldier you’re not going into battle empty-handed. Your ship is equipped with a state of the art laser beam that has unlimited ammo and four smart bombs that will destroy anything on the screen. The ship also has three lives so use them wisely.

As time goes on more alien ships will arrive on planet earth increasing the difficulty of your mission. And remember the landscape bellow loops around so if you continually fly in the same direction you go to your original position. Good luck soldier.

Revision:
16:1ee3d3804557
Parent:
15:90b6821bcf64
Child:
17:25d79cca203a
--- a/GameEngine/GameEngine.cpp	Tue Apr 28 19:13:12 2020 +0000
+++ b/GameEngine/GameEngine.cpp	Tue Apr 28 23:31:22 2020 +0000
@@ -33,17 +33,33 @@
     
     //refresh's screen
     lcd.refresh(); 
+    
+    
+    //draws map again so when moveing mountains are vitable on screen
+    map.draw_map(lcd, move_map_);
+    lcd.refresh();
 }
 
 void GameEngine::calculate_map_movement(){ 
-    // Gets postition of spaceship       
+    // Gets postition of spaceship and sprite direction      
     int position_x_spaceship_= spaceship.get_position_x_spaceship();      
-   
+    
+     
     // moves the map in oposite direction to spaceship when it's position is at min and max x positions and joystick has direction     
-    if (position_x_spaceship_ == 21 && d_ != CENTRE){
+    if (d_ == W || d_ == NW || d_ == SW){
         move_map_ = 1;
-    }else if (position_x_spaceship_ == 53 && d_ != CENTRE){ 
-        move_map_ = -1;  
+        
+        // moves map fater when changing direction to offset ship 
+        if (position_x_spaceship_ != 57){
+            move_map_ = 1;
+        }
+    }else if (d_ == E || d_ == NE || d_ == SE){ 
+        move_map_ = -1; 
+        
+        // moves map fater when changing direction to offset ship
+        if (position_x_spaceship_ != 14){
+            move_map_ = -1;
+        } 
     }else {
         move_map_ = 0;
     }