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:
Wed May 27 02:06:05 2020 +0000
Revision:
87:832ca78426b5
Parent:
86:eecd168c3a23
Final Submission. I have read and agreed with Statement of Academic Integrity.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
evanso 3:dee187b8b30c 1 #ifndef SPACESHIP_H
evanso 3:dee187b8b30c 2 #define SPACESHIP_H
evanso 3:dee187b8b30c 3
evanso 82:3211b31e9421 4 // Included Headers ------------------------------------------------------------
evanso 3:dee187b8b30c 5 #include "mbed.h"
evanso 35:577c65bf914e 6 #include "CheckCollision.h"
evanso 35:577c65bf914e 7 #include "CheckAlienCollision.h"
evanso 7:0af4ced868f5 8
evanso 3:dee187b8b30c 9 /** Spaceship class
evanso 27:8bb2bd97c319 10 * @brief Draws and moves spaceship
evanso 27:8bb2bd97c319 11 * @author Benjamin Evans, University of Leeds
evanso 27:8bb2bd97c319 12 * @date April 2020
evanso 27:8bb2bd97c319 13 */
evanso 35:577c65bf914e 14 class Spaceship: public CheckAlienCollision, public CheckCollision {
evanso 3:dee187b8b30c 15 public:
evanso 3:dee187b8b30c 16 /** Constructor */
evanso 3:dee187b8b30c 17 Spaceship();
evanso 3:dee187b8b30c 18
evanso 3:dee187b8b30c 19 /** Destructor */
evanso 3:dee187b8b30c 20 ~Spaceship();
evanso 3:dee187b8b30c 21
evanso 3:dee187b8b30c 22 /** Initalises Spaceship */
evanso 3:dee187b8b30c 23 void init();
evanso 3:dee187b8b30c 24
evanso 3:dee187b8b30c 25 /** Draws Spaceship
evanso 27:8bb2bd97c319 26 * @param lcd @details N5110 object
evanso 3:dee187b8b30c 27 */
evanso 3:dee187b8b30c 28 void draw(N5110 &lcd);
evanso 3:dee187b8b30c 29
evanso 11:ab578a151f67 30 /** Move Spaceship around the screen depedning on joystick input
evanso 40:71f947254fda 31 * @param d_ @details Direction of joystick
evanso 4:0df2b85e47f1 32 */
evanso 13:12276eed13ac 33 void movement(Direction d_);
evanso 11:ab578a151f67 34
evanso 27:8bb2bd97c319 35 // Accessors and mutators --------------------------------------------------
evanso 11:ab578a151f67 36
evanso 16:1ee3d3804557 37 /** Gets sprtie directon if spaceship
evanso 27:8bb2bd97c319 38 * @return spaceship_sprite_direction_ @details true = east,
evanso 27:8bb2bd97c319 39 * false = west
evanso 16:1ee3d3804557 40 */
evanso 16:1ee3d3804557 41 bool get_spaceship_sprite_direction();
evanso 16:1ee3d3804557 42
evanso 11:ab578a151f67 43 private:
evanso 13:12276eed13ac 44 // Function prototypes -----------------------------------------------------
evanso 11:ab578a151f67 45
evanso 27:8bb2bd97c319 46 /** Sets the x, y position and sprite direction of the spaceship for
evanso 27:8bb2bd97c319 47 * movement function
evanso 27:8bb2bd97c319 48 * @peram x_change
evanso 27:8bb2bd97c319 49 * @peram y_change
evanso 27:8bb2bd97c319 50 * @peram sprite_change
evanso 27:8bb2bd97c319 51 * @peram prite_param
evanso 16:1ee3d3804557 52 */
evanso 27:8bb2bd97c319 53 void set_spaceship_peram(int x_change,int y_change, bool sprite_change,
evanso 27:8bb2bd97c319 54 bool sprite_param);
evanso 11:ab578a151f67 55
evanso 27:8bb2bd97c319 56 /** Checks sapceship x and y position and stops spacship comming of the
evanso 27:8bb2bd97c319 57 * screen in y direction. Keeps spaceship in middle 3rd of screen in
evanso 27:8bb2bd97c319 58 * x direction
evanso 16:1ee3d3804557 59 */
evanso 6:12e8433382b3 60 void off_screen_x_y_checker();
evanso 3:dee187b8b30c 61 };
evanso 3:dee187b8b30c 62
evanso 3:dee187b8b30c 63 #endif