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:
Mon May 04 10:47:06 2020 +0000
Revision:
20:febd920ec29e
Parent:
19:1bc0a2d22054
Child:
21:f7d7834e3af1
Added collision detection so the alien and bullet is deleted if a bullet hits it.

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 19:1bc0a2d22054 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 19:1bc0a2d22054 9
evanso 20:febd920ec29e 10 /** Alien class
evanso 20:febd920ec29e 11 @brief Draws and moves aliens
evanso 19:1bc0a2d22054 12 @author Benjamin Evans, University of Leeds
evanso 19:1bc0a2d22054 13 @date April 2020
evanso 19:1bc0a2d22054 14 */
evanso 19:1bc0a2d22054 15
evanso 19:1bc0a2d22054 16 class Alien {
evanso 19:1bc0a2d22054 17 public:
evanso 19:1bc0a2d22054 18 /** Constructor */
evanso 19:1bc0a2d22054 19 Alien();
evanso 19:1bc0a2d22054 20
evanso 19:1bc0a2d22054 21 /** Destructor */
evanso 19:1bc0a2d22054 22 ~Alien();
evanso 19:1bc0a2d22054 23
evanso 19:1bc0a2d22054 24 /** Initalises Alien */
evanso 19:1bc0a2d22054 25 void init();
evanso 20:febd920ec29e 26
evanso 20:febd920ec29e 27 /** Draws the alien
evanso 20:febd920ec29e 28 * @param lcd @details : N5110 object
evanso 20:febd920ec29e 29 */
evanso 20:febd920ec29e 30 void draw_alien(N5110 &lcd);
evanso 19:1bc0a2d22054 31
evanso 20:febd920ec29e 32 /** Checks if bullet collides with a alien
evanso 20:febd920ec29e 33 * @param lcd @details : N5110 object
evanso 20:febd920ec29e 34 */
evanso 20:febd920ec29e 35 bool check_collision(Weapons bullet);
evanso 19:1bc0a2d22054 36
evanso 19:1bc0a2d22054 37 // Accessors and mutators -----------------------------------------------
evanso 19:1bc0a2d22054 38
evanso 19:1bc0a2d22054 39 void set_position(int position_x_alien, int opsition_y_alien);
evanso 20:febd920ec29e 40
evanso 19:1bc0a2d22054 41 private:
evanso 19:1bc0a2d22054 42 // Function prototypes -----------------------------------------------------
evanso 19:1bc0a2d22054 43
evanso 19:1bc0a2d22054 44
evanso 19:1bc0a2d22054 45 // Variables ---------------------------------------------------------------
evanso 19:1bc0a2d22054 46
evanso 19:1bc0a2d22054 47 //Aliens x position on lcd
evanso 19:1bc0a2d22054 48 int position_x_alien_;
evanso 19:1bc0a2d22054 49
evanso 19:1bc0a2d22054 50 // Aliens y position on lcd
evanso 19:1bc0a2d22054 51 int position_y_alien_;
evanso 19:1bc0a2d22054 52 };
evanso 19:1bc0a2d22054 53
evanso 19:1bc0a2d22054 54 #endif