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.

Committer:
evanso
Date:
Thu May 14 18:34:56 2020 +0000
Revision:
31:6015e8ed859c
Parent:
28:a5958497d5ce
Child:
32:c006a9882778
Added get_pos function to position parent class. Added smart bomb weapon to weapons class.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
evanso 19:1bc0a2d22054 1 #ifndef ALIEN_H
evanso 19:1bc0a2d22054 2 #define ALIEN_H
evanso 19:1bc0a2d22054 3
evanso 27:8bb2bd97c319 4 // Included libraries ----------------------------------------------------------
evanso 19:1bc0a2d22054 5 #include "mbed.h"
evanso 19:1bc0a2d22054 6 #include "N5110.h"
evanso 19:1bc0a2d22054 7 #include "Gamepad.h"
evanso 20:febd920ec29e 8 #include "Weapons.h"
evanso 27:8bb2bd97c319 9 #include "Position.h"
evanso 28:a5958497d5ce 10 #include "RandomMovement.h"
evanso 19:1bc0a2d22054 11
evanso 20:febd920ec29e 12 /** Alien class
evanso 27:8bb2bd97c319 13 * @brief Draws and moves aliens
evanso 27:8bb2bd97c319 14 * @author Benjamin Evans, University of Leeds
evanso 27:8bb2bd97c319 15 * @date May 2020
evanso 27:8bb2bd97c319 16 */
evanso 31:6015e8ed859c 17 class Alien: public RandomMovement {
evanso 19:1bc0a2d22054 18 public:
evanso 19:1bc0a2d22054 19 /** Constructor */
evanso 19:1bc0a2d22054 20 Alien();
evanso 19:1bc0a2d22054 21
evanso 19:1bc0a2d22054 22 /** Destructor */
evanso 19:1bc0a2d22054 23 ~Alien();
evanso 19:1bc0a2d22054 24
evanso 19:1bc0a2d22054 25 /** Initalises Alien */
evanso 24:479da6ca0e7e 26 void init(Gamepad &pad);
evanso 20:febd920ec29e 27
evanso 20:febd920ec29e 28 /** Draws the alien
evanso 27:8bb2bd97c319 29 * @param lcd @details N5110 object
evanso 27:8bb2bd97c319 30 * @param spaceship_pos @details xy spaceship position
evanso 27:8bb2bd97c319 31 * @param d_ @details Direction of joystick
evanso 27:8bb2bd97c319 32 * @param map_length_ @details length of map
evanso 27:8bb2bd97c319 33 * @param position_x_map_ @details x position of map
evanso 20:febd920ec29e 34 */
evanso 27:8bb2bd97c319 35 void draw_alien(N5110 &lcd, Vector2D spaceship_pos, Direction d_,
evanso 27:8bb2bd97c319 36 int map_length_, int position_x_map_);
evanso 19:1bc0a2d22054 37
evanso 20:febd920ec29e 38 /** Checks if bullet collides with a alien
evanso 27:8bb2bd97c319 39 * @param bullet @details Weapons object
evanso 20:febd920ec29e 40 */
evanso 20:febd920ec29e 41 bool check_collision(Weapons bullet);
evanso 19:1bc0a2d22054 42
evanso 21:f7d7834e3af1 43 // Accessors and mutators --------------------------------------------------
evanso 20:febd920ec29e 44
evanso 31:6015e8ed859c 45 /** Gets the counter for alien time to fire
evanso 31:6015e8ed859c 46 * @return alien_fire_counter_
evanso 22:053c11a202e1 47 */
evanso 31:6015e8ed859c 48 int get_alien_fire_counter();
evanso 28:a5958497d5ce 49
evanso 19:1bc0a2d22054 50 private:
evanso 19:1bc0a2d22054 51 // Function prototypes -----------------------------------------------------
evanso 21:f7d7834e3af1 52
evanso 21:f7d7834e3af1 53 /** Moves the alien towards the spaceship and around the map
evanso 21:f7d7834e3af1 54 * @param spaceship_pos @details : Position of the spaceship
evanso 21:f7d7834e3af1 55 */
evanso 24:479da6ca0e7e 56 void move_hunt_mode(Vector2D spaceship_pos);
evanso 21:f7d7834e3af1 57
evanso 27:8bb2bd97c319 58 /** Calulates the aliens movement depeding on spaceship positions and
evanso 27:8bb2bd97c319 59 * joystick input
evanso 21:f7d7834e3af1 60 * @param d_ @details : Direction object of joystick
evanso 21:f7d7834e3af1 61 * @retrun integer @details move alien value for alien draw function
evanso 21:f7d7834e3af1 62 */
evanso 21:f7d7834e3af1 63 int calc_alien_movement(Direction d_);
evanso 19:1bc0a2d22054 64
evanso 27:8bb2bd97c319 65 /** Stops the alien from moving off the edge of the map and moves alien
evanso 27:8bb2bd97c319 66 * if the map loops
evanso 24:479da6ca0e7e 67 * @param map_length_@details : length of the map
evanso 27:8bb2bd97c319 68 * @param position_x_map_ @detials : the drawing start posisiton of the
evanso 27:8bb2bd97c319 69 * map
evanso 24:479da6ca0e7e 70 */
evanso 24:479da6ca0e7e 71 void off_screen_x_y_checker(int map_length_, int position_x_map_);
evanso 24:479da6ca0e7e 72
evanso 19:1bc0a2d22054 73 // Variables ---------------------------------------------------------------
evanso 19:1bc0a2d22054 74
evanso 27:8bb2bd97c319 75 /** Alien movement counter */
evanso 28:a5958497d5ce 76 int alien_move_counter_;
evanso 28:a5958497d5ce 77
evanso 28:a5958497d5ce 78 /** Alien fire bullet counter */
evanso 28:a5958497d5ce 79 int alien_fire_counter_;
evanso 28:a5958497d5ce 80
evanso 19:1bc0a2d22054 81 };
evanso 19:1bc0a2d22054 82
evanso 19:1bc0a2d22054 83 #endif