Ben Evans University Second Year Project. Game Called Defender.
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.
Diff: Alien/Alien.cpp
- Revision:
- 85:87bc28b151d8
- Parent:
- 84:f61c85a5f13a
- Child:
- 86:eecd168c3a23
--- a/Alien/Alien.cpp Tue May 26 14:39:45 2020 +0000 +++ b/Alien/Alien.cpp Tue May 26 19:38:48 2020 +0000 @@ -1,6 +1,6 @@ #include "Alien.h" -// Constant Definisions +// Constant Definitions #define SPRITE_X_LENGTH 7 #define SPRITE_Y_LENGTH 6 @@ -44,8 +44,8 @@ // Moves alien at half speed of spaceship if (alien_move_counter_%2 == 0) { - // Alien tracks spaceship if abducted poeple - if(track_flag_) { + // Alien tracks spaceship if abducted people + if (track_flag_) { move_hunt_mode(spaceship_pos); // printf("tack_flag = %d\n", track_flag_); @@ -55,7 +55,7 @@ }else if (random_move_counter_ == 0 || alien_collision) { // Move alien to top of screen if a collision with person - if(alien_collision) { + if (alien_collision) { random_direction_ = 6; random_move_counter_ = 42; alien_collision = false; @@ -65,8 +65,8 @@ } - // Move alien not tracking spackship move randomley - if(!track_flag_) { + // Move alien not tracking spaceship move randomly + if (!track_flag_) { move_direction(); } @@ -83,19 +83,19 @@ } void Alien::off_screen_x_y_checker(int map_length_, int position_x_map_) { - // Checks y postion of alien and then alters alien movement direction if at + // Checks y position of alien and then alters alien movement direction if at // edge of map if (position_y_ < 9) { - // Sets alien direction to one that increces y value - if(direction_) { + // Sets alien direction to one that increases y value + if (direction_) { random_direction_ = 1; }else{ random_direction_ = 4; } }else if (position_y_ > 42) { - // Sets alien direction to one that decreces y value - if(direction_) { + // Sets alien direction to one that decrees y value + if (direction_) { random_direction_ = 2; }else{ random_direction_ = 5; @@ -103,7 +103,7 @@ } // Loops the alien round if it reaches the end of the map - if(position_x_ <= (84 - map_length_)) { + if (position_x_ <= (84 - map_length_)) { position_x_ += map_length_; }else if (position_x_ >= map_length_) { position_x_ -= map_length_ + 10; @@ -119,15 +119,15 @@ } void Alien::move_hunt_mode(Vector2D spaceship_pos) { - if(spaceship_pos.x < position_x_) { + if (spaceship_pos.x < position_x_) { position_x_ --; - }else if(spaceship_pos.x > position_x_) { + }else if (spaceship_pos.x > position_x_) { position_x_ ++; } - if(spaceship_pos.y > position_y_) { + if (spaceship_pos.y > position_y_) { position_y_ ++; - }else if(spaceship_pos.y < position_y_) { + }else if (spaceship_pos.y < position_y_) { position_y_ --; } } @@ -154,4 +154,4 @@ bool Alien::get_track_flag() { return track_flag_; -} \ No newline at end of file +}