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 33:7fedd8029473 1 #ifndef PEOPLE_H
evanso 33:7fedd8029473 2 #define PEOPLE_H
evanso 33:7fedd8029473 3
evanso 82:3211b31e9421 4 // Included Headers ------------------------------------------------------------
evanso 33:7fedd8029473 5 #include "mbed.h"
evanso 34:85ccc16f24d2 6 #include "RandomMovement.h"
evanso 35:577c65bf914e 7 #include "CheckAlienCollision.h"
evanso 33:7fedd8029473 8
evanso 33:7fedd8029473 9 /** People class
evanso 33:7fedd8029473 10 * @brief Draws people and moves them if collected by aliens
evanso 33:7fedd8029473 11 * @author Benjamin Evans, University of Leeds
evanso 33:7fedd8029473 12 * @date May 2020
evanso 33:7fedd8029473 13 */
evanso 35:577c65bf914e 14 class People: public RandomMovement, public CheckAlienCollision {
evanso 33:7fedd8029473 15 public:
evanso 33:7fedd8029473 16 /** Constructor */
evanso 33:7fedd8029473 17 People();
evanso 33:7fedd8029473 18
evanso 33:7fedd8029473 19 /** Destructor */
evanso 33:7fedd8029473 20 ~People();
evanso 33:7fedd8029473 21
evanso 33:7fedd8029473 22 /** Initalises Alien
evanso 33:7fedd8029473 23 * @param position_x_start @details Random x start pos of people
evanso 82:3211b31e9421 24 * @param pad @detials Gamepad object
evanso 33:7fedd8029473 25 */
evanso 33:7fedd8029473 26 void init(Gamepad &pad, int position_x_start);
evanso 33:7fedd8029473 27
evanso 33:7fedd8029473 28 /** Draws the people
evanso 33:7fedd8029473 29 * @param lcd @details N5110 object
evanso 82:3211b31e9421 30 * @param d_ @details joystick direction
evanso 82:3211b31e9421 31 * @param map_length @details length of the map
evanso 82:3211b31e9421 32 * @param position_x_map_ @details x posisition that map starts
evanso 33:7fedd8029473 33 */
evanso 34:85ccc16f24d2 34 void draw_people(N5110 &lcd, Direction d_, int map_length_,
evanso 34:85ccc16f24d2 35 int position_x_map_);
evanso 33:7fedd8029473 36
evanso 33:7fedd8029473 37 // Accessors and mutators --------------------------------------------------
evanso 34:85ccc16f24d2 38
evanso 34:85ccc16f24d2 39 /** Gets alien collision flag
evanso 34:85ccc16f24d2 40 * @return alien_collision_flag
evanso 34:85ccc16f24d2 41 */
evanso 34:85ccc16f24d2 42 bool get_alien_collision_flag();
evanso 33:7fedd8029473 43
evanso 33:7fedd8029473 44 private:
evanso 33:7fedd8029473 45 // Function prototypes -----------------------------------------------------
evanso 34:85ccc16f24d2 46
evanso 34:85ccc16f24d2 47 /** Stops the people from moving off the edge of the map and moves
evanso 34:85ccc16f24d2 48 * people if the map loops
evanso 34:85ccc16f24d2 49 * @param map_length_@details : length of the map
evanso 34:85ccc16f24d2 50 * @param position_x_map_ @detials : the drawing start posisiton of the
evanso 34:85ccc16f24d2 51 * map
evanso 33:7fedd8029473 52 */
evanso 34:85ccc16f24d2 53 void off_screen_x_y_checker(int map_length_, int position_x_map_);
evanso 33:7fedd8029473 54
evanso 82:3211b31e9421 55 /** Move alien to top of screen if collision with alien */
evanso 36:27aa597db3d2 56 void collision_with_alien();
evanso 36:27aa597db3d2 57
evanso 33:7fedd8029473 58 // Variables ---------------------------------------------------------------
evanso 34:85ccc16f24d2 59
evanso 34:85ccc16f24d2 60 /** People movement counter */
evanso 34:85ccc16f24d2 61 int people_move_counter_;
evanso 33:7fedd8029473 62
evanso 33:7fedd8029473 63 };
evanso 33:7fedd8029473 64
evanso 33:7fedd8029473 65 #endif