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:
85:87bc28b151d8
Final Submission. I have read and agreed with Statement of Academic Integrity.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
evanso 17:25d79cca203a 1 #ifndef WEAPONS_H
evanso 17:25d79cca203a 2 #define WEAPONS_H
evanso 16:1ee3d3804557 3
evanso 82:3211b31e9421 4 // Included Headers ------------------------------------------------------------
evanso 16:1ee3d3804557 5 #include "mbed.h"
evanso 16:1ee3d3804557 6 #include "N5110.h"
evanso 16:1ee3d3804557 7 #include "Gamepad.h"
evanso 28:a5958497d5ce 8 #include "RandomMovement.h"
evanso 16:1ee3d3804557 9
evanso 16:1ee3d3804557 10 /** Weapons class
evanso 27:8bb2bd97c319 11 * @brief Draws and moves weapons
evanso 27:8bb2bd97c319 12 * @author Benjamin Evans, University of Leeds
evanso 27:8bb2bd97c319 13 * @date April 2020
evanso 27:8bb2bd97c319 14 */
evanso 31:6015e8ed859c 15 class Weapons: public RandomMovement {
evanso 16:1ee3d3804557 16 public:
evanso 16:1ee3d3804557 17 /** Constructor */
evanso 16:1ee3d3804557 18 Weapons();
evanso 16:1ee3d3804557 19
evanso 16:1ee3d3804557 20 /** Destructor */
evanso 16:1ee3d3804557 21 ~Weapons();
evanso 16:1ee3d3804557 22
evanso 85:87bc28b151d8 23 /** Initialises Weapons
evanso 28:a5958497d5ce 24 * @param sprite_pos @details vector 2D of sprite xy position
evanso 28:a5958497d5ce 25 * @param sprite_direction @details sprite direction bool,
evanso 27:8bb2bd97c319 26 * true = E, false = W
evanso 28:a5958497d5ce 27 * @param bullet_type @details true = spaceship, false = alien
evanso 27:8bb2bd97c319 28 */
evanso 28:a5958497d5ce 29 void init(Vector2D sprite_pos, bool sprite_direction,bool bullet_type);
evanso 16:1ee3d3804557 30
evanso 18:11068b98e261 31 /** Draws the bullet and moves it in x direction each frame
evanso 27:8bb2bd97c319 32 * @param lcd @details N5110 object
evanso 18:11068b98e261 33 */
evanso 18:11068b98e261 34 void draw_bullet(N5110 &lcd);
evanso 28:a5958497d5ce 35
evanso 28:a5958497d5ce 36 /** Draws the aliens bullet and moves it in xy direction each frame
evanso 28:a5958497d5ce 37 * @param lcd @details N5110 object
evanso 28:a5958497d5ce 38 * @param d_ @details : Direction object of joystick
evanso 28:a5958497d5ce 39 */
evanso 28:a5958497d5ce 40 void draw_alien_bullet(N5110 &lcd, Direction d_);
evanso 31:6015e8ed859c 41
evanso 31:6015e8ed859c 42 /** Tuns lcd back light on and off
evanso 31:6015e8ed859c 43 * @param lcd @details N5110 object
evanso 31:6015e8ed859c 44 */
evanso 31:6015e8ed859c 45 void smart_bomb(N5110 &lcd);
evanso 18:11068b98e261 46
evanso 22:053c11a202e1 47 // Accessors and mutators --------------------------------------------------
evanso 18:11068b98e261 48
evanso 82:3211b31e9421 49 /** Sets the xy position of the bullet
evanso 22:053c11a202e1 50 * @param pos @details vector 2D of bullet xy position
evanso 22:053c11a202e1 51 */
evanso 22:053c11a202e1 52 void set_pos_one(Vector2D pos);
evanso 22:053c11a202e1 53
evanso 20:febd920ec29e 54 /** Gets the bullet distance counter
evanso 27:8bb2bd97c319 55 * @return bullet_distance_counter
evanso 20:febd920ec29e 56 */
evanso 20:febd920ec29e 57 int get_bullet_delete_counter();
evanso 20:febd920ec29e 58
evanso 20:febd920ec29e 59 /** Gets the bullet direction
evanso 27:8bb2bd97c319 60 * @return bullet_direction_
evanso 20:febd920ec29e 61 */
evanso 20:febd920ec29e 62 bool get_direction();
evanso 19:1bc0a2d22054 63
evanso 85:87bc28b151d8 64 /** Sets the bullets movement direction when it is fired
evanso 27:8bb2bd97c319 65 * @param spaceship_sprite_direction_ @details sprite direction bool,
evanso 27:8bb2bd97c319 66 * true = E, false = W
evanso 19:1bc0a2d22054 67 */
evanso 28:a5958497d5ce 68 void set_direction(bool sprite_direction_);
evanso 18:11068b98e261 69
evanso 22:053c11a202e1 70 private:
evanso 22:053c11a202e1 71 // Function prototypes -----------------------------------------------------
evanso 22:053c11a202e1 72
evanso 85:87bc28b151d8 73 /** Calculates bullets start position
evanso 19:1bc0a2d22054 74 * @param spaceship_pos @details x and y postion of spaceship
evanso 27:8bb2bd97c319 75 * @param spaceship_sprite_direction_ @details sprite direction bool,
evanso 27:8bb2bd97c319 76 * true = E, false = W
evanso 19:1bc0a2d22054 77 */
evanso 27:8bb2bd97c319 78 void calc_bullets_start_pos(Vector2D spaceship_pos,
evanso 27:8bb2bd97c319 79 bool spaceship_sprite_direction_);
evanso 28:a5958497d5ce 80
evanso 85:87bc28b151d8 81 /** Calculates alien bullets start position
evanso 28:a5958497d5ce 82 * @param alien_pos @details x and y postion of spaceship
evanso 28:a5958497d5ce 83 * @param alien_sprite_direction_ @details sprite direction bool,
evanso 28:a5958497d5ce 84 * true = E, false = W
evanso 28:a5958497d5ce 85 */
evanso 28:a5958497d5ce 86 void calc_alien_bullets_start_pos(Vector2D alien_pos,
evanso 28:a5958497d5ce 87 bool alien_sprite_direction_);
evanso 20:febd920ec29e 88
evanso 16:1ee3d3804557 89 // Variables ---------------------------------------------------------------
evanso 16:1ee3d3804557 90
evanso 27:8bb2bd97c319 91 /** Counter to deleted bullet */
evanso 28:a5958497d5ce 92 int bullet_delete_counter_;
evanso 16:1ee3d3804557 93 };
evanso 16:1ee3d3804557 94
evanso 85:87bc28b151d8 95 #endif