Ben Evans / Mbed 2 deprecated Defender_Game

Dependencies:   mbed

Committer:
evanso
Date:
Mon May 25 18:39:51 2020 +0000
Revision:
82:3211b31e9421
Parent:
36:27aa597db3d2
Child:
86:eecd168c3a23
Made commenting and formatting of code more consistent.

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