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.

Files at this revision

API Documentation at this revision

Comitter:
evanso
Date:
Wed May 13 14:30:12 2020 +0000
Parent:
26:1a7056eb3253
Child:
28:a5958497d5ce
Commit message:
Added position parent class for other classes to inherit XY positions and direction bool. Added more Doxygen comments. Made code and comments multi-line to increase readability.

Changed in this revision

Alien/Alien.cpp Show annotated file Show diff for this revision Revisions of this file
Alien/Alien.h Show annotated file Show diff for this revision Revisions of this file
Alien/Alien_test.h Show annotated file Show diff for this revision Revisions of this file
Explosion/Explosion.cpp Show annotated file Show diff for this revision Revisions of this file
Explosion/Explosion.h Show annotated file Show diff for this revision Revisions of this file
Explosion/Explosion_test.h Show annotated file Show diff for this revision Revisions of this file
GameEngine/GameEngine.cpp Show annotated file Show diff for this revision Revisions of this file
GameEngine/GameEngine.h Show annotated file Show diff for this revision Revisions of this file
GameEngine/GameEngine_test.h Show annotated file Show diff for this revision Revisions of this file
Map/Map.cpp Show annotated file Show diff for this revision Revisions of this file
Map/Map.h Show annotated file Show diff for this revision Revisions of this file
Map/Map_test.h Show annotated file Show diff for this revision Revisions of this file
Position/Position.h Show annotated file Show diff for this revision Revisions of this file
Spaceship/Spaceship.cpp Show annotated file Show diff for this revision Revisions of this file
Spaceship/Spaceship.h Show annotated file Show diff for this revision Revisions of this file
Spaceship/Spaceship_test.h Show annotated file Show diff for this revision Revisions of this file
Weapons/Weapons.cpp Show annotated file Show diff for this revision Revisions of this file
Weapons/Weapons.h Show annotated file Show diff for this revision Revisions of this file
Weapons/Weapons_test.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
test.h Show annotated file Show diff for this revision Revisions of this file
--- a/Alien/Alien.cpp	Wed May 13 12:02:51 2020 +0000
+++ b/Alien/Alien.cpp	Wed May 13 14:30:12 2020 +0000
@@ -18,18 +18,19 @@
 }
 
 void Alien::init(Gamepad &pad) {
-    position_x_alien_ = 10;
-    position_y_alien_ = 22;
+    position_x_ = 10;
+    position_y_ = 22;
     alien_move_counter = 0;
     srand(pad.read_adc()*64000);
     random_move_counter_ = 0;
     random_direction_ = 0;
-    alien_general_direction = rand()%2;
+    direction_ = rand()%2;
 }
  
-void Alien::draw_alien(N5110 &lcd,Vector2D spaceship_pos,Direction d_, int map_length_, int position_x_map_) {
+void Alien::draw_alien(N5110 &lcd,Vector2D spaceship_pos,Direction d_, 
+int map_length_, int position_x_map_) {
     //moves alien spaceship movemen 
-    position_x_alien_ += calc_alien_movement(d_);
+    position_x_ += calc_alien_movement(d_);
     
     //Alien moves on its own but at half speed of spaceship 
     if (alien_move_counter%2 == 0) {
@@ -44,12 +45,12 @@
     }
     alien_move_counter++;
     
-    lcd.drawSprite(position_x_alien_, position_y_alien_, 6, 7, (int*)k_alien_sprite);
+    lcd.drawSprite(position_x_, position_y_, 6, 7, (int*)k_alien_sprite);
 }
 
 void Alien::set_random_move(){
     // alien only moves in one general direction
-    if(alien_general_direction){
+    if(direction_){
         random_direction_ = rand() % 3;
     }else{
         random_direction_ = rand() % 3 + 3;
@@ -59,17 +60,18 @@
 }
 
 void Alien::off_screen_x_y_checker(int map_length_, int position_x_map_){
-    // checks y postion of alien and then alters moement direction if at edge of map
-    if (position_y_alien_ < 0) {
+    // checks y postion of alien and then alters moement direction if at edge of 
+    // map
+    if (position_y_ < 0) {
         // sets alien direction to one that increces y value 
-        if(alien_general_direction){
+        if(direction_){
             random_direction_ = 1;
         }else{
             random_direction_ = 4;
         }
-    }else if (position_y_alien_ > 40) {
+    }else if (position_y_ > 40) {
         // sets alien direction to one that decreces y value 
-        if(alien_general_direction){
+        if(direction_){
             random_direction_ = 2;
         }else{
             random_direction_ = 5;
@@ -77,18 +79,19 @@
     } 
     
     // loops the alien round if it reaches the end of the map 
-    if(position_x_alien_ <= (84 - map_length_)){
-       position_x_alien_ += map_length_; 
-    }else if (position_x_alien_ >= map_length_){
-        position_x_alien_ -= map_length_ + 10;
+    if(position_x_ <= (84 - map_length_)){
+       position_x_ += map_length_; 
+    }else if (position_x_ >= map_length_){
+        position_x_ -= map_length_ + 10;
     }   
     
     // Debug and check variables when defined  
     #ifdef CALCULATE_ALIEN_MOVEMENT_DEBUG   
         printf("\nposition_x_map_ =  %d\n", position_x_map_);
         printf("map_length_  =  %d\n", map_length_ );
-        printf("map_length_ + position_x_map_ =  %d\n", map_length_ + position_x_map_);
-        printf("alien x pos = %d\n",position_x_alien_);
+        printf("map_length_ + position_x_map_ =  %d\n", map_length_ + 
+        position_x_map_);
+        printf("alien x pos = %d\n",position_x_);
     #endif
 }   
 
@@ -104,10 +107,10 @@
 }
 
 void Alien::move_hunt_mode(Vector2D spaceship_pos){
-    if(spaceship_pos.x <= position_x_alien_){
-       position_x_alien_ --;
+    if(spaceship_pos.x <= position_x_){
+       position_x_ --;
     }else{
-        position_x_alien_ ++;
+        position_x_ ++;
     }
 }
 
@@ -120,10 +123,11 @@
         Vector2D bullet_pos_two = bullet.get_pos_two();
         //int bullet_pos_twox = bullet_pos_two.x;
         //int bullet_pos_twoy = bullet_pos_two.y;
-        //printf ("alien x  = %d, bullet x = %d\n", position_x_alien_,bullet_pos_twox );
-        //printf ("alien y  = %d, bullet y = %d\n", position_y_alien_,bullet_pos_twoy );
+        //printf ("alien x = %d, bullet x = %d\n", position_x_,bullet_pos_twox);
+        //printf ("alien y = %d, bullet y = %d\n", position_y_,bullet_pos_twoy);
         
-        if(bullet_pos_two.x >= position_x_alien_ && position_y_alien_ <= bullet_pos_two.y && bullet_pos_two.y <= (position_y_alien_ + 7)){
+        if(bullet_pos_two.x >= position_x_ && position_y_ <= bullet_pos_two.y && 
+        bullet_pos_two.y <= (position_y_ + 7)){
             collision = true;
         }
     //printf ("Collision 2 = %d\n", collision);  
@@ -131,17 +135,22 @@
     // checks collision if bullet is going in west direction 
     }else if(!bullet.get_direction()){
         Vector2D bullet_pos_one = bullet.get_pos_one();
-        if(bullet_pos_one.x <= position_x_alien_ + 6 && position_y_alien_ <= bullet_pos_one.y && bullet_pos_one.y <= (position_y_alien_ + 7)){
+        if(bullet_pos_one.x <= position_x_ + 6 && 
+        position_y_ <= bullet_pos_one.y && 
+        bullet_pos_one.y <= (position_y_ + 7)){
             collision = true;
         }
+        
      //printf ("Collision 3 = %d\n", collision);   
     }
+    
     //printf ("Collision 4 = %d\n", collision);   
     return collision;
 }
 
 int Alien::calc_alien_movement(Direction d_){  
-    // moves the alien in oposite direction to spaceship when it's position is at min and max x positions and joystick has direction     
+    // moves the alien 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){ 
@@ -152,12 +161,11 @@
 }
 
 Vector2D Alien::get_pos(){
-    Vector2D pos = {position_x_alien_,position_y_alien_};
+    Vector2D pos = {position_x_,position_y_};
     return pos;
 }
 
 void Alien::set_alien_direction(int x_change,int y_change){
-    position_x_alien_ += x_change;
-    position_y_alien_ += y_change;
-}
-
+    position_x_ += x_change;
+    position_y_ += y_change;
+}
\ No newline at end of file
--- a/Alien/Alien.h	Wed May 13 12:02:51 2020 +0000
+++ b/Alien/Alien.h	Wed May 13 14:30:12 2020 +0000
@@ -1,19 +1,19 @@
 #ifndef ALIEN_H
 #define ALIEN_H
  
-// Included libraries -----------------------------------------------------------
+// Included libraries ----------------------------------------------------------
 #include "mbed.h"
 #include "N5110.h"
 #include "Gamepad.h"
 #include "Weapons.h"
+#include "Position.h"
 
 /** Alien class
-@brief Draws and moves aliens 
-@author Benjamin Evans, University of Leeds
-@date May 2020
-*/
- 
-class Alien {
+ * @brief Draws and moves aliens 
+ * @author Benjamin Evans, University of Leeds
+ * @date May 2020
+ */ 
+class Alien: private Position {
     public:
         /** Constructor */
         Alien();
@@ -25,19 +25,25 @@
         void init(Gamepad &pad);
     
         /** Draws the alien
-         * @param lcd @details : N5110 object
+         * @param lcd @details N5110 object
+         * @param spaceship_pos @details xy spaceship position
+         * @param d_ @details Direction of joystick
+         * @param map_length_ @details length of map
+         * @param position_x_map_ @details x position of map
          */
-        void draw_alien(N5110 &lcd,Vector2D spaceship_pos,Direction d_, int map_length_, int position_x_map_);
+        void draw_alien(N5110 &lcd, Vector2D spaceship_pos, Direction d_, 
+        int map_length_, int position_x_map_);
         
         /** Checks if bullet collides with a alien 
-         * @param lcd @details : N5110 object
+         * @param bullet @details Weapons object
          */
         bool check_collision(Weapons bullet);
     
     // Accessors and mutators --------------------------------------------------
     
         /** Gets the xy position of the alien
-         * @returns position_x_alien_, position_x_alien_
+         * @return position_x_alien_ 
+         * @return position_x_alien_
          */
         Vector2D get_pos();
     
@@ -49,7 +55,8 @@
          */
         void move_hunt_mode(Vector2D spaceship_pos);
        
-        /** Calulates the aliens movement depeding on spaceship positions and joystick input 
+        /** Calulates the aliens movement depeding on spaceship positions and 
+         * joystick input 
          * @param d_ @details : Direction object of joystick
          * @retrun integer @details move alien value for alien draw function 
          */
@@ -61,39 +68,31 @@
         /** Gets the movement direction of the alien */
         void move_direction();
         
-        /** Changes the x and y positions of the alien depeding on the movement direction 
-         * @param x_change @details : number to change alien x position by
-         * @param y_change @detials : number to change alien y position by
+        /** Changes the x and y positions of the alien depeding on the movement 
+         * direction 
+         * @param x_change @details number to change alien x position by
+         * @param y_change @detials number to change alien y position by
          */
         void set_alien_direction(int x_change,int y_change);
         
-        /** Stops the alien from moving off the edge of the map and moves alien if the map loops
+        /** Stops the alien from moving off the edge of the map and moves alien 
+         * if the map loops
          * @param map_length_@details : length of the map  
-         * @param position_x_map_ @detials : the drawing start posisiton of the map 
+         * @param position_x_map_ @detials : the drawing start posisiton of the 
+         * map 
          */
         void off_screen_x_y_checker(int map_length_, int position_x_map_);
         
     // Variables ---------------------------------------------------------------
          
-        //Aliens x position on lcd
-        int position_x_alien_;
-            
-        // Aliens y position on lcd
-        int position_y_alien_;
-        
-        // Alien movement counter
-        int alien_move_counter; 
-        
-        // Alien randome move counter 
+        /** Alien movement counter */
+        int alien_move_counter;
+         
+        /** Alien randome move counter */
         int random_move_counter_;
-        
-        // Random direction variable
-        int random_direction_;    
-        
-        // Aliens genreal movement direction, 1 = East , 0 = West 
-        int alien_general_direction;
-        
-        
+         
+        /** Random direction variable */
+        int random_direction_;     
 };
  
 #endif
\ No newline at end of file
--- a/Alien/Alien_test.h	Wed May 13 12:02:51 2020 +0000
+++ b/Alien/Alien_test.h	Wed May 13 14:30:12 2020 +0000
@@ -2,13 +2,13 @@
 #define ALIEN_TEST_H
 
 /** Alien Test
-@brief Checks that the alien draws, moves and detects collisions
-@author Benjamin Evans, University of Leeds
-@date May 2020
-@return true if test are passed 
-*/
-
-bool alien_collision_test(bool expected_collision, bool bullet_direction,int position_x_bullet,int position_y_bullet){
+ * @brief Checks that the alien draws, moves and detects collisions
+ * @author Benjamin Evans, University of Leeds
+ * @date May 2020
+ * @return true if test are passed 
+ */
+bool alien_collision_test(bool expected_collision, bool bullet_direction,
+int position_x_bullet,int position_y_bullet){
     // Objects reqired for test 
     Alien alien;
     Weapons bullet;
@@ -32,12 +32,15 @@
         printf ( "Passed!\n");
         return true;
     } else {
-        printf ("Failed! value = %s (expecting  %d)\n", actual_collision ? "true" : "false", expected_collision ? "true" : "false");
+        printf ("Failed! value = %s (expecting  %d)\n", 
+        actual_collision ? "true" : "false", 
+        expected_collision ? "true" : "false");
         return false;
     } 
 }
 
-bool alien_movement_test(int random_direction, int expected_x_move, int expected_y_move){
+bool alien_movement_test(int random_direction, int expected_x_move, 
+int expected_y_move){
     // Objects reqired for test 
     Gamepad pad;
     Alien alien;
@@ -54,22 +57,27 @@
     Vector2D start_postion = alien.get_pos();
     int start_x_postion = start_postion.x;
     int start_y_postion = start_postion.y;
-    printf("move_alien = %d,%d : ", start_x_postion + expected_x_move, start_y_postion + expected_y_move);
+    printf("move_alien = %d,%d : ", start_x_postion + expected_x_move, 
+    start_y_postion + expected_y_move);
     
     // Moves alien
-    alien.draw_alien(lcd,start_postion,d_, map.get_length_map(), map.get_position_x_map());
+    alien.draw_alien(lcd,start_postion,d_, map.get_length_map(), 
+    map.get_position_x_map());
     
     //Reads finish alien positon 
     Vector2D finish_postion = alien.get_pos();
     
     // Checks final position with espected
-    if (finish_postion.x == start_postion.x + expected_x_move && start_postion.y + expected_y_move) {
+    if (finish_postion.x == start_postion.x + expected_x_move && 
+    start_postion.y + expected_y_move) {
         printf ( "Passed!\n");
         return true;
     } else {
         int finish_x_postion = finish_postion.x ;
         int finish_y_postion = finish_postion.y ;
-        printf ("Failed! value = %d,%d (expecting  %d,%d)\n", finish_x_postion, finish_y_postion, start_x_postion + expected_x_move, start_y_postion + expected_x_move);
+        printf ("Failed! value = %d,%d (expecting  %d,%d)\n", finish_x_postion, 
+        finish_y_postion, start_x_postion + expected_x_move, 
+        start_y_postion + expected_x_move);
         return false;
     } 
 }
--- a/Explosion/Explosion.cpp	Wed May 13 12:02:51 2020 +0000
+++ b/Explosion/Explosion.cpp	Wed May 13 14:30:12 2020 +0000
@@ -3,8 +3,7 @@
 // Defining animation states for explotion FSM
 Animation animation_fsm[2] = {
     {false, true, FILL_WHITE, FILL_BLACK},
-    {true, false, FILL_TRANSPARENT, FILL_WHITE},
-    
+    {true, false, FILL_TRANSPARENT, FILL_WHITE},   
 };
 
 Explosion::Explosion() {
@@ -16,8 +15,8 @@
 }
 
 void Explosion::init() {
-    position_x_explosion_ = 0;
-    position_y_explosion_ = 0;
+    position_x_ = 0;
+    position_y_ = 0;
     fsm_counter_ = 0;  
     explosion_radius_ = 4;
     draw_counter = 0;
@@ -26,10 +25,12 @@
 void Explosion::draw_explosion(N5110 &lcd) {
     // Draws each explotion frame depending on state 
     if(animation_fsm[fsm_counter_].draw_circle_one){
-        lcd.drawCircle(position_x_explosion_, position_y_explosion_,explosion_radius_ + 1, animation_fsm[fsm_counter_].circle_one);
+        lcd.drawCircle(position_x_, position_y_,explosion_radius_ + 1, 
+        animation_fsm[fsm_counter_].circle_one);
     }
     if(animation_fsm[fsm_counter_].draw_circle_two){
-        lcd.drawCircle(position_x_explosion_, position_y_explosion_,(explosion_radius_ - 2), animation_fsm[fsm_counter_].circle_two);
+        lcd.drawCircle(position_x_, position_y_,(explosion_radius_ - 2), a
+        nimation_fsm[fsm_counter_].circle_two);
     }
     
     // Slows down annimation change time, so eplosion animation is longer
@@ -41,8 +42,8 @@
 }
 
 void Explosion::set_explosion_posistion(Vector2D destroyed_position) {
-    position_x_explosion_ = destroyed_position.x + 3; 
-    position_y_explosion_ = destroyed_position.y + 3; 
+    position_x_ = destroyed_position.x + 3; 
+    position_y_ = destroyed_position.y + 3; 
 }
 
 int Explosion::get_explosion_radius(){
--- a/Explosion/Explosion.h	Wed May 13 12:02:51 2020 +0000
+++ b/Explosion/Explosion.h	Wed May 13 14:30:12 2020 +0000
@@ -1,28 +1,29 @@
 #ifndef EXPLOSION_H
 #define EXPLOSION_H
 
-// Included libraries -----------------------------------------------------------
+// Included libraries ----------------------------------------------------------
 #include "mbed.h"
 #include "N5110.h"
 #include "Gamepad.h"
+#include "Position.h"
 #include <vector>
 
+/** Animation Struct
+ * @brief Struct to draw explosion animation 
+ */   
+struct Animation{
+    bool draw_circle_one; /**< Bool to draw circle one */
+    bool draw_circle_two; /**< Bool to draw circle two */
+    FillType circle_one; /**< Fill type of circle one */
+    FillType circle_two; /**< Fill type of circle two */
+};
+
 /** Explosion class
-@brief Draws explosion animation 
-@author Benjamin Evans, University of Leeds
-@date May 2020
-*/      
-
-// struct to draw explosion animation 
-struct Animation{
-    bool draw_circle_one; 
-    bool draw_circle_two;
-    FillType circle_one; 
-    FillType circle_two;
-};
-    
-
-class Explosion {
+ * @brief Draws explosion animation 
+ * @author Benjamin Evans, University of Leeds
+ * @date May 2020
+ */      
+class Explosion: private Position {
     public:
         /** Constructor */
         Explosion();
@@ -34,14 +35,14 @@
         void init();
     
         /** Draws the explosion 
-         * @param lcd @details : N5110 object
+         * @param lcd @details N5110 object
          */
         void draw_explosion(N5110 &lcd);
     
     // Accessors and mutators --------------------------------------------------
         
         /** Set position of the explosion
-         * @param destroyed_position @details : xy position of object that was detroyed
+         * @param destroyed_position @details xy position of destroyed object
          */
         void set_explosion_posistion(Vector2D destroyed_position);
         
@@ -53,20 +54,14 @@
     private:   
        
     // Varibles ---------------------------------------------------------------- 
-         
-        //Explosion x position on lcd
-        int position_x_explosion_;
-            
-        // Explosion y position on lcd
-        int position_y_explosion_;
         
-        // Explosion circle radius
+        /** Explosion circle radius */ 
         int explosion_radius_;
         
-        // FSM counter
+        /** FSM counter for state in FSM */ 
         int fsm_counter_;
         
-        // Draw cunter 
+        /** Draw cunter  */
         int draw_counter;
 };
  
--- a/Explosion/Explosion_test.h	Wed May 13 12:02:51 2020 +0000
+++ b/Explosion/Explosion_test.h	Wed May 13 14:30:12 2020 +0000
@@ -2,13 +2,13 @@
 #define EXPLOSION_TEST_H
 
 /** EXPLOSION Test
-@brief Checks explosion animation is drawn 
-@author Benjamin Evans, University of Leeds
-@date May 2020
-@return true if test are passed 
-*/
-
-bool explosion_draw_test(int expected_pixel_status, int expected_postion_x, int expected_postion_y){
+ * @brief Checks explosion animation is drawn 
+ * @author Benjamin Evans, University of Leeds
+ * @date May 2020
+ * @return true if test are passed 
+ */
+bool explosion_draw_test(int expected_pixel_status, int expected_postion_x, 
+int expected_postion_y){
     // Objects reqired for test 
     Gamepad pad;
     Explosion explosion;
@@ -20,7 +20,8 @@
     explosion.init(); 
     
     // Reads start spaceship postion 
-    printf("explosion_draw x,y= %d,%d : ",expected_postion_x, expected_postion_y );
+    printf("explosion_draw x,y= %d,%d : ",expected_postion_x, 
+    expected_postion_y);
     
     //sets position of explotion
     Vector2D destroyed_position = {expected_postion_x, expected_postion_y};
@@ -30,14 +31,16 @@
     explosion.draw_explosion(lcd);
     
     // Reads pixel where explosion is expected to be drawn 
-    int actual_pixel_status = lcd.getPixel(expected_postion_x + 3, expected_postion_y + 3);
+    int actual_pixel_status = lcd.getPixel(expected_postion_x + 3, 
+    expected_postion_y + 3);
     
     // Checks if pixel is drawn and therefor testing it hasnt gone of screen
     if (actual_pixel_status) {
         printf ( "Passed!\n");
         return true;
     } else {
-        printf ( "Failed! value = %d  (expecting  %d)\n", actual_pixel_status, expected_pixel_status);
+        printf ( "Failed! value = %d  (expecting  %d)\n", actual_pixel_status, 
+        expected_pixel_status);
         return false;
     }
 }
--- a/GameEngine/GameEngine.cpp	Wed May 13 12:02:51 2020 +0000
+++ b/GameEngine/GameEngine.cpp	Wed May 13 14:30:12 2020 +0000
@@ -46,7 +46,8 @@
         // Bullet object
         Weapons new_bullet;
         
-        new_bullet.init(spaceship.get_pos(), spaceship.get_spaceship_sprite_direction());
+        new_bullet.init(spaceship.get_pos(), 
+        spaceship.get_spaceship_sprite_direction());
         
         // Stores bullet object in vector 
         bullet_vector.push_back(new_bullet);
@@ -74,12 +75,14 @@
 }
 
 void GameEngine::draw_bullets(){
-    // interates over bullet vector and get each new_bullet object to draw its self and move
+    // interates over bullet vector and get each new_bullet object to draw its 
+    // self and move
     for (int i = 0; i < bullet_vector.size(); i++){
         bullet_vector[i].draw_bullet(lcd);
         
         // deletes bullet object after bullet is out of view of paceship    
-        int bullet_delete_counter = bullet_vector[i].get_bullet_delete_counter();
+        int bullet_delete_counter = 
+        bullet_vector[i].get_bullet_delete_counter();
         if(bullet_delete_counter >> 5){
              bullet_vector.erase(bullet_vector.begin()+ i);
         }
@@ -87,14 +90,16 @@
 }
 
 void GameEngine::draw_aliens(){
-    // interates over alien vector and get each new_alien object to draw its self
+    // interates over alien vector and each new_alien object to draw its self
     for (int i = 0; i < alien_vector.size(); i++){
-        alien_vector[i].draw_alien(lcd,spaceship.get_pos(),d_, map.get_length_map(), map.get_position_x_map());
+        alien_vector[i].draw_alien(lcd,spaceship.get_pos(),d_, 
+        map.get_length_map(), map.get_position_x_map());
         
         // Deletes bullet and alien if collision detected
         if (alien_vector[i].check_collision(bullet_vector[i])){
             create_explosion();
-            explosion_vector[i].set_explosion_posistion(alien_vector[i].get_pos()); 
+            explosion_vector[i].set_explosion_posistion(
+            alien_vector[i].get_pos()); 
             
             bullet_vector.erase(bullet_vector.begin()+ i);    
             alien_vector.erase(alien_vector.begin()+ i);  
@@ -103,7 +108,8 @@
 }
 
 void GameEngine::draw_explosions(){
-    // interates over expoltion vector and draws each explosion object then deleted object after set size
+    // interates over expoltion vector and draws each explosion object then 
+    // deleted object after set size
     for (int i = 0; i < explosion_vector.size(); i++){
         explosion_vector[i].draw_explosion(lcd);
         
--- a/GameEngine/GameEngine.h	Wed May 13 12:02:51 2020 +0000
+++ b/GameEngine/GameEngine.h	Wed May 13 14:30:12 2020 +0000
@@ -1,7 +1,7 @@
 #ifndef GAMEENGINE_H
 #define GAMEENGINE_H
  
-// Included libraries -----------------------------------------------------------
+// Included libraries ----------------------------------------------------------
 #include "mbed.h"
 #include "N5110.h"
 #include "Gamepad.h"
@@ -11,14 +11,12 @@
 #include "Alien.h"
 #include "Explosion.h"
 #include <vector>
-
  
 /** GameEngine class
-@brief Runs the different parts of the game 
-@author Benjamin Evans, University of Leeds
-@date April 2020
-*/
-
+ * @brief Runs the different parts of the game 
+ * @author Benjamin Evans, University of Leeds
+ * @date April 2020
+ */
 class GameEngine {
     public:
         /** Constructor */
@@ -33,62 +31,65 @@
         /** Main gameplay loop that runs playable part of game */
         void gameplay_loop();
         
-    // Accessors and mutators ----------------------------------------------
+    // Accessors and mutators --------------------------------------------------
           
     private:
-    // Function prototypes -------------------------------------------------
+    // Function prototypes -----------------------------------------------------
         
-        /** Gets joystick direction from gamepad and stores it in d_*/
+        /** Gets joystick direction from gamepad and stores it in d_ */
         void read_joystick_direction();
         
-        /** Creats bullet object if button A is pressed and stores in vector*/
+        /** Creats bullet object if button A is pressed and stores in vector */
         void create_bullet();
        
-        /** Draws each bullet object and deleted object after set movement distance*/
+        /** Draws each bullet object and deleted object after set movement 
+         * distance
+         */
         void draw_bullets();
         
         /** Creats alien object and stores in vector*/
         void create_alien();
         
-        /** Draws each alien object and deletes both objects if collision detected*/
+        /** Draws each alien object and deletes both objects if collision 
+         * detected 
+         */
         void draw_aliens();
         
-        /** Creats bullet object if button A is pressed and stores in vector*/
+        /** Creats bullet object if button A is pressed and stores in vector */
         void create_explosion();
        
-        /** Draws each explosion object if collision detected*/
+        /** Draws each explosion object if collision detected */
         void draw_explosions();
         
-    // Variables -----------------------------------------------------------
+    // Variables ---------------------------------------------------------------
         
-        // Direction of joystick
+        /** Define direction d of joystick*/
         Direction d_; 
         
-    // Vectors ----------------------------------------------------------------  
-      
-        // Vector to store each new bullet object
+    // Vectors -----------------------------------------------------------------  
+        
+        /** Vector to store each new bullet object*/
         std::vector<Weapons> bullet_vector;
         
-        // Vector to store each new alien object
+        /** Vector to store each new alien object*/
         std::vector<Alien> alien_vector;
         
-        // Vector to store each new eplosion object
+        /** Vector to store each new eplosion object*/
         std::vector<Explosion> explosion_vector;
         
-    // Objects -------------------------------------------------------------
-    
-        // Gamepad object 
+    // Objects -----------------------------------------------------------------
+        
+        /** Define Gamepad object*/ 
         Gamepad pad;
         
-        // LCD object
+        /** Define LCD object*/
         N5110 lcd;
         
-        // Spaceship object 
+        /** Define Spaceship object */
         Spaceship spaceship;
         
-        // Map object 
+        /** Define Map object*/
         Map map; 
- 
 };
  
 #endif
\ No newline at end of file
--- a/GameEngine/GameEngine_test.h	Wed May 13 12:02:51 2020 +0000
+++ b/GameEngine/GameEngine_test.h	Wed May 13 14:30:12 2020 +0000
@@ -2,10 +2,10 @@
 #define GAMEENGINE_TEST_H
 
 /** GameEngine Test
-@brief Checks that the calulate_map_movement caluclates the correct map_movement
-@author Benjamin Evans, University of Leeds
-@date April 2020
-@return true if test are passed 
-*/
+ * @brief Checks that the calulate_map_movement caluclates correct map_movement
+ * @author Benjamin Evans, University of Leeds
+ * @date April 2020
+ * @return true if test are passed 
+ */
 
 #endif
\ No newline at end of file
--- a/Map/Map.cpp	Wed May 13 12:02:51 2020 +0000
+++ b/Map/Map.cpp	Wed May 13 14:30:12 2020 +0000
@@ -14,8 +14,8 @@
 
 void Map::init(Gamepad &pad) {
     map_length_ = MAP_TERRAIN_X_LENGTH;
-    position_x_map_ = MAP_TERRAIN_X_POSITION;
-    position_y_map_ = MAP_TERRAIN_Y_POSITION;
+    position_x_ = MAP_TERRAIN_X_POSITION;
+    position_y_ = MAP_TERRAIN_Y_POSITION;
     
     // Initialises random arrays to make random map
     fill_random_arrays(pad);
@@ -39,25 +39,30 @@
 
 void Map::draw_triangle(N5110 &lcd,int triangle_height){ 
     // draws triangle by drawing two lines with one line having negative gadient 
-    lcd.drawLine(position_x_map_, position_y_map_, position_x_map_ + triangle_height, position_y_map_ - triangle_height,1); 
-    lcd.drawLine(position_x_map_ + triangle_height, position_y_map_ - triangle_height,position_x_map_ + 2*triangle_height,position_y_map_,1);
+    lcd.drawLine(position_x_, position_y_, position_x_ + triangle_height, 
+    position_y_ - triangle_height,1); 
+    lcd.drawLine(position_x_ + triangle_height, position_y_ - triangle_height,
+    position_x_ + 2*triangle_height,position_y_,1);
     
-    // changes the position of the map next draw line starts at the end of the drawn triangle
-    position_x_map_ = position_x_map_ + 2*triangle_height,position_y_map_;
+    // changes the position of the map next draw line starts at the end of the 
+    // drawn triangle
+    position_x_ = position_x_ + 2*triangle_height,position_y_;
 }
 
 void Map::draw_line(N5110 &lcd,int line_length){ 
-    lcd.drawLine(position_x_map_, position_y_map_, position_x_map_ + line_length, position_y_map_,1);
+    lcd.drawLine(position_x_, position_y_, position_x_ + line_length, 
+    position_y_,1);
     
-    // changes the position of the map next draw triangle starts at the end of the drawn line
-    position_x_map_ += line_length;
+    // changes the position of the map next draw triangle starts at the end of 
+    // the drawn line
+    position_x_ += line_length;
 }
 
 void Map::draw_map(N5110 &lcd, Direction d_){
-    //printf("position_x_map_ map = %d\n", position_x_map_);
+    //printf("position_x_ map = %d\n", position_x_);
     //usb.printf("move map = %d\n", move_map);
     
-    reset_position_x_map_to_origonal_ = position_x_map_;
+    reset_position_x_map_to_origonal_ = position_x_;
     map_length_ = 0;
     
     //prints main part of map
@@ -69,7 +74,8 @@
         // calculates the length of the random map produced
         map_length_ += rand_lengths_[i] + 2*rand_heights_[i];
         
-        // stops random maps lengths being to large only want it about 3 screen widths
+        // stops random maps lengths being to large only want it about 3 screen 
+        // widths
         if (map_length_ >252){ 
             break;
         }
@@ -80,18 +86,19 @@
     check_duplicates_map_backwards(lcd);
     
     // Resets postion of map and moves it 
-    position_x_map_ = reset_position_x_map_to_origonal_ + calc_map_movement(d_);
+    position_x_ = reset_position_x_map_to_origonal_ + calc_map_movement(d_);
     
     // Moves map to different persition so make it look like its looping 
-    if(position_x_map_+ map_length_ < 0){
-       position_x_map_ = 0;
-    } else if(position_x_map_ > 84){
-        position_x_map_ = 84 - map_length_;
+    if(position_x_+ map_length_ < 0){
+       position_x_ = 0;
+    } else if(position_x_ > 84){
+        position_x_ = 84 - map_length_;
     }
 }
 
 void Map::check_duplicates_map_forward(N5110 &lcd){ 
-    // Prints 1st part of map to fill gap wear map isn't present just befor its about to loop round it's self
+    // Prints 1st part of map to fill gap wear map isn't present just befor its 
+    // about to loop round it's self
     if(reset_position_x_map_to_origonal_ + map_length_ <84 ){
         for(int i = 0; i < 4; i++){
             draw_triangle(lcd,rand_heights_[i]);
@@ -102,16 +109,20 @@
 }
 
 void Map::check_duplicates_map_backwards(N5110 &lcd){
-    // Prints last part of map to fill gap wear map isn't present just befor its about to loop round it's self
+    // Prints last part of map to fill gap wear map isn't present just befor its 
+    // about to loop round it's self
     if(reset_position_x_map_to_origonal_ > 0 ){
         int print_reverse_position = 0;
         
         // prints the last 4 parts of map to fill gap
-        for(int i = final_random_element_used_ ; i > final_random_element_used_ - 4; i--){
-            position_x_map_ = reset_position_x_map_to_origonal_ - rand_lengths_[i] - print_reverse_position;
+        for(int i = final_random_element_used_ ;
+         i > final_random_element_used_ - 4; i--){
+            position_x_ = reset_position_x_map_to_origonal_ - rand_lengths_[i] - 
+            print_reverse_position;
             draw_line(lcd,rand_lengths_[i]);
             print_reverse_position += rand_lengths_[i];
-            position_x_map_ = reset_position_x_map_to_origonal_ - 2*rand_heights_[i] - print_reverse_position;
+            position_x_ = reset_position_x_map_to_origonal_ - 2*rand_heights_[i]
+            - print_reverse_position;
             draw_triangle(lcd,rand_heights_[i]);
             print_reverse_position += 2*rand_heights_[i];
         }
@@ -119,7 +130,8 @@
 }
 
 int Map::calc_map_movement(Direction d_){  
-    // moves the map in oposite direction to spaceship when it's position is at min and max x positions and joystick has direction     
+    // moves the map 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){ 
@@ -137,7 +149,7 @@
 }
 
 int Map::get_position_x_map(){
-    return position_x_map_;
+    return position_x_;
 }
 
 int Map::get_length_map(){
--- a/Map/Map.h	Wed May 13 12:02:51 2020 +0000
+++ b/Map/Map.h	Wed May 13 14:30:12 2020 +0000
@@ -1,18 +1,18 @@
 #ifndef MAP_H
 #define MAP_H
  
-// Included libraries -----------------------------------------------------------
+// Included libraries ----------------------------------------------------------
 #include "mbed.h"
 #include "N5110.h"
 #include "Gamepad.h"
+#include "Position.h"
 
 /** Map class
-@brief Draws 
-@author Benjamin Evans, University of Leeds
-@date April 2020
-*/
-
-class Map {
+ * @brief Draws 
+ * @author Benjamin Evans, University of Leeds
+ * @date April 2020
+ */
+class Map: private Position{
     public:
         /** Constructor */
         Map();
@@ -27,77 +27,85 @@
         
         /** Draws map out of combination of random hight traingle and random 
          * length lines so map is differnt each new game and loops roudn at ends
-         * @param lcd, d_ @details : N5110 object and Direction variable for move map
+         * @param lcd @details N5110 object and 
+         * @param d_ @details Direction variable for move map
          */
         void draw_map(N5110 &lcd, Direction d_);
     
-    // Accessors and mutators ----------------------------------------------
+    // Accessors and mutators --------------------------------------------------
         
         /** Gets x postion of the map for testing 
          * @return maps x postion 
          */
         int get_position_x_map();
         
+        /** Gets map length
+         * @return map_length_ 
+         */
         int get_length_map();
        
     private:
-    // Functions prototypes ------------------------------------------------
+    // Functions prototypes ----------------------------------------------------
     
-        /** Draws a triangle from position with specified hight wich represents a mountain of the map
-         * @param lcd, tirangle_height @details : N5110 object and teh random hight of triangle produced
+        /** Draws a triangle from position with specified hight wich represents 
+         * a mountain of the map
+         * @param lcd @details N5110 object 
+         * @param triangle_height @details random hight of triangle produced
          */
         void draw_triangle(N5110 &lcd, int triangle_height);
         
-        /** Draws a horizontal line with specified length to represent flat land on map
-         * @param lcd, tirangle_height @details : N5110 object and random length of line produced
+        /** Draws a horizontal line with specified length to represent flat land 
+         * on map
+         * @param lcd @details N5110 object
+         * @param line_length @details length of horozontal line
          */
         void draw_line(N5110 &lcd, int line_length);
         
-        /** Duplicates the first part of the map to fill the gap when the map loops round
-         * @ param lcd @details : N5110 object
+        /** Duplicates the first part of the map to fill the gap when the map 
+         * loops round forwards
+         * @ param lcd @details N5110 object
          */
         void check_duplicates_map_forward(N5110 &lcd);
     
-        /** Duplicates the last part of the map to fill the gap when the map loops round
-         * @ param lcd @details : N5110 object
+        /** Duplicates the last part of the map to fill the gap when the map 
+         * loops round backwards
+         * @ param lcd @details  N5110 object
          */
         void check_duplicates_map_backwards(N5110 &lcd);
         
-        /** Gets 11 random integers for random lengths and hights arrays 
-         * and fills arrays with  the random integers so same random map is drawn each frame
+        /** Fills random lengths and hights arrays and fills arrays with random 
+         * integers so same random map is drawn each frame
          * @param Pad @details : Gampad adc object used to generate seed 
          */
         void fill_random_arrays(Gamepad &pad);
         
-        /** Calulates the map movement depeding on spaceship positions and joystick input 
-         * @param d_ @details : Direction object of joystick
-         * @retrun inger @details move map value for map draw function 
+        /** Calulates the map movement depeding on spaceship positions and 
+         * joystick input 
+         * @param d_ @details Direction object of joystick
+         * @retrun inger @details Move map value for map draw function 
          */
         int calc_map_movement(Direction d_);
     
-    // Variables -----------------------------------------------------------
+    // Variables ---------------------------------------------------------------
         
-        // Map y postion on lcd
-        int position_y_map_;
+        /** store random heights triangles */
+        int rand_heights_[12]; 
         
-        // Float to store random seed for random function 
-        float rand_seed_;
+        /** store lengths of lines */
+        int rand_lengths_[12]; 
         
-        // Arrays to hold random heights of triangles and lengths of lines
-        int rand_heights_[12]; 
-        int rand_lengths_[12];
-        
-        // To store the final element used in the random array befor the break in draw map
+        /** To store the final element used in the random array befor the break
+         * in draw map 
+         */
         int final_random_element_used_; 
         
-        //Required to reset the map to it's origonal postion at end of each frame, as draw line and triangle functions change position_x_map_
-        int reset_position_x_map_to_origonal_;    
+        /** Required to reset the map to it's origonal postion at end of each  
+         * frame, as draw line and triangle functions change position_x_map_ 
+         */  
+        int reset_position_x_map_to_origonal_;  
           
-        // Map length 
-        int map_length_;
-        
-        // Map x postion on lcd
-        int position_x_map_;
+        /** Length of map */
+        int map_length_; 
 };
  
 #endif
\ No newline at end of file
--- a/Map/Map_test.h	Wed May 13 12:02:51 2020 +0000
+++ b/Map/Map_test.h	Wed May 13 14:30:12 2020 +0000
@@ -1,14 +1,13 @@
 #ifndef MAP_TEST_H
 #define MAP_TEST_H
 
-
 /** Map Test
-@brief Checks that the map moves to the correct x position depedning on joystick input
-@author Benjamin Evans, University of Leeds
-@date April 2020
-@return true if test are passed 
-*/
-
+ * @brief Checks that the map moves to the correct x position depedning on 
+ * joystick input
+ * @author Benjamin Evans, University of Leeds
+ * @date April 2020
+ * @return true if test are passed 
+ */
 bool map_move_test(Direction d_, int expected_x_position){
     // Objects reqired for test
     Gamepad pad;
@@ -34,7 +33,8 @@
         printf ( "Passed!\n");
         return true;
     } else {
-        printf ( "Failed! value = %d,  (expecting  %d)\n",map_start_draw_postion, expected_x_position);
+        printf ( "Failed! value = %d,  (expecting  %d)\n",
+        map_start_draw_postion, expected_x_position);
         return false;
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Position/Position.h	Wed May 13 14:30:12 2020 +0000
@@ -0,0 +1,29 @@
+#ifndef POSITION_H
+#define POSITION_H
+
+// Included libraries ----------------------------------------------------------
+#include "mbed.h"
+
+/** Position class
+* @brief Postition perant class
+* @author Benjamin Evans, University of Leeds
+* @date May 2020
+*/         
+class Position {
+    public:
+        
+    protected:   
+       
+    // Varibles ---------------------------------------------------------------- 
+        
+        /** x position on lcd */
+        int position_x_; 
+        
+        /** y position on lcd */     
+        int position_y_; 
+        
+        /** Movement direction true = East, false = West */
+        bool direction_; 
+};
+ 
+#endif
\ No newline at end of file
--- a/Spaceship/Spaceship.cpp	Wed May 13 12:02:51 2020 +0000
+++ b/Spaceship/Spaceship.cpp	Wed May 13 14:30:12 2020 +0000
@@ -23,44 +23,47 @@
 }
  
 void Spaceship::init() {
-    position_x_spaceship_ = 36;
-    position_y_spaceship_ = 22;
+    position_x_ = 36;
+    position_y_ = 22;
     
     // sets origonal spaceship direction to facing East
-    spaceship_sprite_direction_ = true;
+    direction_ = true;
 }
  
 void Spaceship::draw(N5110 &lcd) {
     off_screen_x_y_checker();
     
-    // Draws spaceships at defined x and y positions with different sprite direction depending on joystick postion 
-    if (spaceship_sprite_direction_){
-        lcd.drawSprite(position_x_spaceship_, position_y_spaceship_, 4, 13, (int*)k_spaceship_sprite_E);
-    }else if (!spaceship_sprite_direction_){
-    lcd.drawSprite(position_x_spaceship_, position_y_spaceship_, 4, 13, (int*)k_spaceship_sprite_W);
+    // Draws spaceships at defined x and y positions with different sprite 
+    // direction depending on joystick postion 
+    if (direction_){
+        lcd.drawSprite(position_x_, position_y_, 4, 13, 
+        (int*)k_spaceship_sprite_E);
+    }else if (!direction_){
+    lcd.drawSprite(position_x_, position_y_, 4, 13, (int*)k_spaceship_sprite_W);
     }
     
-    //usb.printf("Spaceship Y postion = %d\n",position_y_spaceship_);
+    //usb.printf("Spaceship Y postion = %d\n",position_y_);
 }
 
 void Spaceship::off_screen_x_y_checker(){
     // checks y postion of spaceship and then alters y position if off map
-    if (position_y_spaceship_ < 0) {
-        position_y_spaceship_ = 0;
-    }else if (position_y_spaceship_ > 44) {
-        position_y_spaceship_ = 44;
+    if (position_y_ < 0) {
+        position_y_ = 0;
+    }else if (position_y_ > 44) {
+        position_y_ = 44;
     }  
     
     // checks x postion of spaceship and alters x position 
-    if (position_x_spaceship_ > 56) {
-        position_x_spaceship_ = 56;
-    }else if (position_x_spaceship_ < 15) {
-        position_x_spaceship_ = 15;
+    if (position_x_ > 56) {
+        position_x_ = 56;
+    }else if (position_x_ < 15) {
+        position_x_ = 15;
     }
 }   
  
 void Spaceship::movement(Direction d_){
-    // switch statement to change spaceship parameters depedning on joystick direction
+    // switch statement to change spaceship parameters depedning on 
+    // joystick direction
     switch (d_) {
     case CENTRE: set_spaceship_peram(0, 0, false , false); break;
     case N: set_spaceship_peram(0, -1, false , false); break;
@@ -72,27 +75,26 @@
     case W: set_spaceship_peram(1, 0, true, false); break;
     case NW: set_spaceship_peram(1, -1, true, false); break;
     }
-    //printf("y= %d\n", position_y_spaceship_);
+    
+    //printf("y= %d\n", position_y_);
 }
 
-void Spaceship::set_spaceship_peram(int x_change,int y_change, bool sprite_change, bool sprite_param){
-    position_x_spaceship_ += x_change;
-    position_y_spaceship_ += y_change;
+void Spaceship::set_spaceship_peram(int x_change,int y_change, 
+bool sprite_change, bool sprite_param){
+    position_x_ += x_change;
+    position_y_ += y_change;
     
     // Only changes sprite direction when jostick direction isn't N or S
     if (sprite_change) {
-        spaceship_sprite_direction_ = sprite_param;
+        direction_ = sprite_param;
     }
 }
 
 Vector2D Spaceship::get_pos(){
-    Vector2D pos = {position_x_spaceship_,position_y_spaceship_};
+    Vector2D pos = {position_x_,position_y_};
     return pos;
 }
 
 bool Spaceship::get_spaceship_sprite_direction(){
-    return spaceship_sprite_direction_;
-}
-
-
-
+    return direction_;
+}
\ No newline at end of file
--- a/Spaceship/Spaceship.h	Wed May 13 12:02:51 2020 +0000
+++ b/Spaceship/Spaceship.h	Wed May 13 14:30:12 2020 +0000
@@ -1,18 +1,18 @@
 #ifndef SPACESHIP_H
 #define SPACESHIP_H
  
-// Included libraries -----------------------------------------------------------
+// Included libraries ----------------------------------------------------------
 #include "mbed.h"
 #include "N5110.h"
 #include "Gamepad.h"
+#include "Position.h"
 
 /** Spaceship class
-@brief Draws and moves spaceship
-@author Benjamin Evans, University of Leeds
-@date April 2020
-*/
- 
-class Spaceship {
+ * @brief Draws and moves spaceship
+ * @author Benjamin Evans, University of Leeds
+ * @date April 2020
+ */
+class Spaceship: private Position{
     public:
         /** Constructor */
         Spaceship();
@@ -24,52 +24,47 @@
         void init();
         
         /** Draws Spaceship 
-         * @param lcd @details : N5110 object
+         * @param lcd @details N5110 object
          */
         void draw(N5110 &lcd);
         
         /** Move Spaceship around the screen depedning on joystick input
-         * @param d_ @details : Direction object of joystick
+         * @param d_ @details Direction object of joystick
          */
         void movement(Direction d_);   
         
-    // Accessors and mutators -----------------------------------------------
+    // Accessors and mutators --------------------------------------------------
         
         /** Gets sprtie directon if spaceship 
-         * @details true = east, false = west
-         * @return spaceship_sprite_direction_ 
+         * @return spaceship_sprite_direction_ @details true = east, 
+         * false = west
          */
         bool get_spaceship_sprite_direction(); 
         
         /** Gets the xy position of the spaceship 
-         * @returns position_x_spaceship_, position_x_spaceship_
+         * @return position_x_spaceship_
+         * @return position_y_spaceship_
          */
         Vector2D get_pos();
         
     private:
     // Function prototypes -----------------------------------------------------
     
-        /** Sets the x, y position and sprite direction of the spaceship for movement function  
-         * @peram x_change, y_change, sprite_change, sprite_param 
+        /** Sets the x, y position and sprite direction of the spaceship for
+         * movement function  
+         * @peram x_change 
+         * @peram y_change
+         * @peram sprite_change
+         * @peram prite_param 
          */
-        void set_spaceship_peram(int x_change,int y_change, bool sprite_change, bool sprite_param);
+        void set_spaceship_peram(int x_change,int y_change, bool sprite_change, 
+        bool sprite_param);
         
-        /** Checks sapceship x and y position and stops spacship comming of the screen in y direction
-         * holds spaceship in middle 3rd of screen in x direction 
+        /** Checks sapceship x and y position and stops spacship comming of the 
+         * screen in y direction. Keeps spaceship in middle 3rd of screen in 
+         * x direction 
          */
         void off_screen_x_y_checker();
-        
-    // Variables ---------------------------------------------------------------
-    
-        // Spaceships x position on lcd
-        int position_x_spaceship_;
-        
-        // Spaceships y position on lcd
-        int position_y_spaceship_;
-        
-        // Boolean flag for if sprite direction is changed
-        bool spaceship_sprite_direction_;
-        
 };
  
 #endif
\ No newline at end of file
--- a/Spaceship/Spaceship_test.h	Wed May 13 12:02:51 2020 +0000
+++ b/Spaceship/Spaceship_test.h	Wed May 13 14:30:12 2020 +0000
@@ -2,12 +2,12 @@
 #define SPACESHIP_TEST_H
 
 /** Spaceship Test
-@brief Checks Spcaceship move to the correct postion when moved and doesnt go of map when being drawn
-@author Benjamin Evans, University of Leeds
-@date April 2020
-@return true if test are passed 
-*/
-
+ * @brief Checks Spcaceship move to the correct postion when moved and doesnt go 
+ * of map when being drawn
+ * @author Benjamin Evans, University of Leeds
+ * @date April 2020
+ * @return true if test are passed 
+ */
 bool spaceship_movement_test(Direction d_, int expected_x,int expected_y){
     // Objects reqired for test 
     Gamepad pad;
@@ -32,13 +32,15 @@
     } else {
         int finish_x_postion = finish_postion.x;
         int finish_y_postion = finish_postion.y;
-        printf ( "Failed! value = %d,%d (expecting  %d,%d)\n", finish_x_postion, finish_y_postion, expected_x, expected_y);
+        printf ( "Failed! value = %d,%d (expecting  %d,%d)\n", finish_x_postion, 
+        finish_y_postion, expected_x, expected_y);
         return false;
     }
     
 }
 
-bool spaceship_draw_test(Direction d_, int expected_pixel_status, int expected_postion_x, int expected_postion_y){
+bool spaceship_draw_test(Direction d_, int expected_pixel_status, 
+int expected_postion_x, int expected_postion_y){
     // Objects reqired for test 
     Gamepad pad;
     Spaceship spaceship;
@@ -50,9 +52,11 @@
     spaceship.init(); 
     
     // Reads start spaceship postion 
-    printf("spaceship_draw x,y= %d,%d : ",expected_postion_x, expected_postion_y );
+    printf("spaceship_draw x,y= %d,%d : ",expected_postion_x, 
+    expected_postion_y );
     
-    // Moves spcaeship to max/min x and y postions to test off_screen_x_y_checker
+    // Moves spcaeship to max/min x and y postions to test 
+    // off_screen_x_y_checker
     for (int i = 0; i < 30; i++){
         spaceship.movement(d_);
     }
@@ -61,14 +65,16 @@
     spaceship.draw(lcd);
     
     // Reads pixel where spaceship is expected to be drawn 
-    int actual_pixel_status = lcd.getPixel(expected_postion_x, expected_postion_y);
+    int actual_pixel_status = lcd.getPixel(expected_postion_x, 
+    expected_postion_y);
     
     // Checks if pixel is drawn and therefor testing it hasnt gone of screen
     if (actual_pixel_status) {
         printf ( "Passed!\n");
         return true;
     } else {
-        printf ( "Failed! value = %d  (expecting  %d)\n", actual_pixel_status, expected_pixel_status);
+        printf ( "Failed! value = %d  (expecting  %d)\n", actual_pixel_status, 
+        expected_pixel_status);
         return false;
     }
 }
--- a/Weapons/Weapons.cpp	Wed May 13 12:02:51 2020 +0000
+++ b/Weapons/Weapons.cpp	Wed May 13 14:30:12 2020 +0000
@@ -14,28 +14,29 @@
     bullet_delete_cunter_ = 0;
 }
 
-void Weapons::calc_bullets_start_pos(Vector2D spaceship_pos, bool spaceship_sprite_direction_){
+void Weapons::calc_bullets_start_pos(Vector2D spaceship_pos, 
+bool spaceship_sprite_direction_){
     // Sets start position of bullet to spaceships nose
     if (spaceship_sprite_direction_){
-        position_x_bullet_ = spaceship_pos.x + 13;
-        position_y_bullet_ = spaceship_pos.y + 2;
+        position_x_ = spaceship_pos.x + 13;
+        position_y_ = spaceship_pos.y + 2;
     }else{
-        position_x_bullet_ = spaceship_pos.x;
-        position_y_bullet_ = spaceship_pos.y + 2;
+        position_x_ = spaceship_pos.x;
+        position_y_ = spaceship_pos.y + 2;
     }
     #ifdef POSITION_BULLET_DEBUG   
-        printf("X = %d\n", position_x_bullet_);       
-        printf("Y = %d\n", position_y_bullet_);
+        printf("X = %d\n", position_x_);       
+        printf("Y = %d\n", position_y_);
     #endif 
 }
 
 void Weapons::draw_bullet(N5110 &lcd){
     // draws then moves the bullet position
-    lcd.drawLine(position_x_bullet_, position_y_bullet_, position_x_bullet_+1, position_y_bullet_, 1);
-    if(bullet_direction_){
-        position_x_bullet_ += 3;
+    lcd.drawLine(position_x_, position_y_, position_x_+1, position_y_, 1);
+    if(direction_){
+        position_x_ += 3;
     }else{
-        position_x_bullet_ -= 3;
+        position_x_ -= 3;
     }
     
     // increments counter
@@ -43,22 +44,22 @@
 }
 
 Vector2D Weapons::get_pos_one(){
-    Vector2D pos = {position_x_bullet_,position_y_bullet_};
+    Vector2D pos = {position_x_,position_y_};
     return pos;
 }
 
 void Weapons::set_pos_one(Vector2D pos){
-    position_x_bullet_ = pos.x;
-    position_y_bullet_ = pos.y;
+    position_x_ = pos.x;
+    position_y_ = pos.y;
 }
 
 Vector2D Weapons::get_pos_two(){
-    Vector2D pos = {position_x_bullet_+1,position_y_bullet_};
+    Vector2D pos = {position_x_+1,position_y_};
     return pos;
 }
 
 void Weapons::set_direction(bool spaceship_sprite_direction){
-    bullet_direction_ = spaceship_sprite_direction;   
+    direction_ = spaceship_sprite_direction;   
 }
 
 int Weapons::get_bullet_delete_counter(){
@@ -66,5 +67,5 @@
 }
 
 bool Weapons::get_direction(){
- return bullet_direction_;   
+    return direction_;   
 }
\ No newline at end of file
--- a/Weapons/Weapons.h	Wed May 13 12:02:51 2020 +0000
+++ b/Weapons/Weapons.h	Wed May 13 14:30:12 2020 +0000
@@ -5,14 +5,14 @@
 #include "mbed.h"
 #include "N5110.h"
 #include "Gamepad.h"
+#include "Position.h"
 
 /** Weapons class
-@brief Draws and moves weapons 
-@author Benjamin Evans, University of Leeds
-@date April 2020
-*/
- 
-class Weapons {
+ * @brief Draws and moves weapons 
+ * @author Benjamin Evans, University of Leeds
+ * @date April 2020
+ */
+class Weapons: private Position{
     public:
         /** Constructor */
         Weapons();
@@ -20,18 +20,23 @@
         /** Destructor */
         ~Weapons();
         
-        /** Initalises Weapons */
+        /** Initalises Weapons 
+         * @param spaceship_pos @details vector 2D of bullet xy position 
+         * @param paceship_sprite_direction @details sprite direction bool, 
+         * true = E, false = W
+         */
         void init(Vector2D spaceship_pos, bool spaceship_sprite_direction);
         
         /** Draws the bullet and moves it in x direction each frame
-         * @param lcd @details : N5110 object
+         * @param lcd @details N5110 object
          */
         void draw_bullet(N5110 &lcd);
          
     // Accessors and mutators --------------------------------------------------
           
         /** Gets the xy position of the bullet 
-         * @returns position_x_bullet_, position_x_bullet_
+         * @return position_x_bullet_
+         * @return position_x_bullet_
          */
         Vector2D get_pos_one();
         
@@ -41,22 +46,24 @@
         void set_pos_one(Vector2D pos);
         
         /** Gets the 2nd xy position of the bullet for colition detection 
-         * @returns position_x_bullet_ + 1, position_x_bullet_
+         * @return position_x_bullet_ + 1 
+         * @return position_x_bullet_
          */
         Vector2D get_pos_two();
         
         /** Gets the bullet distance counter 
-         * @returns bullet_distance_counter
+         * @return bullet_distance_counter
          */
         int get_bullet_delete_counter();
         
         /** Gets the bullet direction
-         * @returns bullet_direction_
+         * @return bullet_direction_
          */
         bool get_direction();
         
         /** Sets the bullets movment direction when it is fired
-         * @param spaceship_sprite_direction_ @details sprite direction bool, true = E, false = W
+         * @param spaceship_sprite_direction_ @details sprite direction bool, 
+         * true = E, false = W
          */
         void set_direction(bool spaceship_sprite_direction_);
         
@@ -65,24 +72,16 @@
     
         /** Calculates bullets start postion
          * @param spaceship_pos @details x and y postion of spaceship
-         * @param spaceship_sprite_direction_ @details sprite direction bool, true = E, false = W
+         * @param spaceship_sprite_direction_ @details sprite direction bool, 
+         * true = E, false = W
          */
-        void calc_bullets_start_pos(Vector2D spaceship_pos, bool spaceship_sprite_direction_);
+        void calc_bullets_start_pos(Vector2D spaceship_pos, 
+        bool spaceship_sprite_direction_);
     
     // Variables ---------------------------------------------------------------
-         
-        // Bullets x position on lcd
-        int position_x_bullet_;
         
-        // Bullets y position on lcd
-        int position_y_bullet_;
-        
-        // Bullet movement direction
-        bool bullet_direction_;
-        
-        // Counter to delected bullet after certan distance 
-        int bullet_delete_cunter_;
-    
+        /** Counter to deleted bullet */
+        int bullet_delete_cunter_; 
 };
  
 #endif
\ No newline at end of file
--- a/Weapons/Weapons_test.h	Wed May 13 12:02:51 2020 +0000
+++ b/Weapons/Weapons_test.h	Wed May 13 14:30:12 2020 +0000
@@ -2,13 +2,13 @@
 #define WEAPONS_TEST_H
 
 /** Weapons Test
-@brief Checks that the weapons draws
-@author Benjamin Evans, University of Leeds
-@date May 2020
-@return true if test are passed 
-*/
-
-bool weapons_draw_test(int expected_pixel_status,bool direction, int bullet_movement, int expected_postion_x, int expected_postion_y){
+ * @brief Checks that the weapons draws
+ * @author Benjamin Evans, University of Leeds
+ * @date May 2020
+ * @return true if test are passed 
+ */
+bool weapons_draw_test(int expected_pixel_status,bool direction, 
+int bullet_movement, int expected_postion_x, int expected_postion_y){
     // Objects reqired for test 
     Weapons bullet;
     Spaceship spaceship;
@@ -27,14 +27,16 @@
     }
     
     // Reads pixel where bullet is expected to be drawn 
-    int actual_pixel_status = lcd.getPixel(expected_postion_x, expected_postion_y);
+    int actual_pixel_status = lcd.getPixel(expected_postion_x, 
+    expected_postion_y);
     
     // Checks if pixel is drawn and therefor testing it hasnt gone of screen
     if (actual_pixel_status) {
         printf ( "Passed!\n");
         return true;
     } else {
-        printf ( "Failed! value = %d  (expecting  %d)\n", actual_pixel_status, expected_pixel_status);
+        printf ( "Failed! value = %d  (expecting  %d)\n", actual_pixel_status, 
+        expected_pixel_status);
         return false;
     }
 }
--- a/main.cpp	Wed May 13 12:02:51 2020 +0000
+++ b/main.cpp	Wed May 13 14:30:12 2020 +0000
@@ -2,8 +2,6 @@
 ELEC2645 Embedded Systems Project
 School of Electronic & Electrical Engineering
 University of Leeds
-2019/20
-
 Name:Benjamin Evans
 Username:el18bpe
 Student ID Number:201216635
@@ -23,29 +21,25 @@
 #endif
 
 // TO DO
-// change comment so nulti line 
-// seperate details comments 
-// do params on seperate line and have seperate detials for each one
-// make code multi line seperate at and statments 
 // deffine headers porperly by commenting out and compiling 
-// change commenting type to /*....*/ for all variables
-// make position class and inheret 
-// fix alien test 
+// fix alien test by doing random movement test
 
 // Objects ---------------------------------------------------------------------
 
-// Ticker object for ISR
+/** Define Ticker object for ISR*/ 
 Ticker ticker; 
 
-//Game Engine object
+/** Define Game Engine object*/ 
 GameEngine engine;
 
 // Global variables ------------------------------------------------------------
 
-// Volatile flag for ISR 
+/** Volatile flag for ISR */
 volatile int g_lcd_frame_time_flag = 0;  
 
 // Function prototypes ---------------------------------------------------------
+
+/** Time-triggered interrupt to wake MCU from sleep */
 void lcd_frame_time_isr();
 
 // functions -------------------------------------------------------------------
@@ -70,7 +64,8 @@
         
         // Checks flag and prints spaceship on lcd then resets flag
         if (g_lcd_frame_time_flag) {
-            g_lcd_frame_time_flag = 0; // resets flag 
+            // resets ISR flag 
+            g_lcd_frame_time_flag = 0; 
             
             engine.gameplay_loop();   
         }
@@ -80,7 +75,7 @@
     } 
 }
 
-// Time-triggered interrupt to wake MCU from sleep
 void lcd_frame_time_isr(){
-    g_lcd_frame_time_flag = 1;   // set flag in ISR
+    // set ISR flag
+    g_lcd_frame_time_flag = 1; 
 }
\ No newline at end of file
--- a/test.h	Wed May 13 12:02:51 2020 +0000
+++ b/test.h	Wed May 13 14:30:12 2020 +0000
@@ -9,11 +9,11 @@
 #include "Explosion_test.h"
  
 /** Test
-@brief Runs all tests for game 
-@author Benjamin Evans, University of Leeds
-@date April 2020 
-*/
-
+ * @brief Runs all tests for game 
+ * @author Benjamin Evans, University of Leeds
+ * @date April 2020 
+ */
+ 
 // Spaceship tests -------------------------------------------------------------
 void run_spaceship_movement_tests(){
     printf ("\nTesting spaceship_movement_test() \n");
@@ -31,7 +31,8 @@
     if (spaceship_movement_test(NW, 37, 21)) passed_counter++;
     
     // prints results
-    printf ("\nspaceship_movement_test passed %d tests out of 9\n",passed_counter);
+    printf ("\nspaceship_movement_test passed %d tests out of 9\n",
+    passed_counter);
 }
 
 void run_spaceship_draw_tests(){
@@ -100,7 +101,7 @@
     printf ("\nalien_movement_test passed %d tests out of 4\n",passed_counter);
 }
 
-// Weapons tests -----------------------------------------------------------------
+// Weapons tests ---------------------------------------------------------------
 void run_weapons_draw_tests(){
     printf ("\nTesting spaceship_draw_tests() \n");
     int passed_counter = 0;
@@ -117,7 +118,7 @@
     printf ("\nspaceship_draw_test passed %d tests out of 6\n",passed_counter);
 }
 
-// Explosion tests -----------------------------------------------------------------
+// Explosion tests -------------------------------------------------------------
 void run_explosion_draw_tests(){
     printf ("\nTesting explosion_draw_tests() \n");
     int passed_counter = 0;
@@ -131,4 +132,5 @@
     // prints results
     printf ("\nspaceship_draw_test passed %d tests out of 4\n",passed_counter);
 }
+
 #endif
\ No newline at end of file