Ben Evans University Second Year Project. Game Called Defender.
Embed:
(wiki syntax)
Show/hide line numbers
Alien.h
00001 #ifndef ALIEN_H 00002 #define ALIEN_H 00003 00004 // Included Headers ------------------------------------------------------------ 00005 #include "mbed.h" 00006 #include "N5110.h" 00007 #include "RandomMovement.h" 00008 #include "CheckCollision.h" 00009 00010 /** Alien class 00011 * @brief Draws and moves aliens 00012 * @author Benjamin Evans, University of Leeds 00013 * @date May 2020 00014 */ 00015 class Alien: public RandomMovement, public CheckCollision { 00016 public: 00017 /** Constructor */ 00018 Alien(); 00019 00020 /** Destructor */ 00021 ~Alien(); 00022 00023 /** Initialises Alien 00024 * @param position_x_start @details Random x start pos of alien 00025 * @param position_y_start @details Random y start pos of alien 00026 * @param pad @details Gamepad object 00027 */ 00028 void init(Gamepad &pad, int position_x_start, int position_y_start); 00029 00030 /** Draws the alien 00031 * @param lcd @details N5110 object 00032 * @param spaceship_pos @details xy spaceship position 00033 * @param d_ @details Direction of joystick 00034 * @param map_length_ @details length of map 00035 * @param position_x_map_ @details x position of map 00036 * @param alien_collision @details bool if a collision happened 00037 */ 00038 void draw_alien(N5110 &lcd, Vector2D spaceship_pos, Direction d_, 00039 int map_length_, int position_x_map_, bool alien_collision); 00040 00041 // Accessors and mutators -------------------------------------------------- 00042 00043 /** Gets the counter for alien time to fire 00044 * @return alien_fire_counter_ 00045 */ 00046 int get_alien_fire_counter(); 00047 00048 /** Sets the position_x_ of alien 00049 * @param position_x 00050 */ 00051 void set_alien_x_pos(int position_x); 00052 00053 /** Sets the collision_people_element number 00054 * @param people_element 00055 */ 00056 void set_collision_people_element(int people_element); 00057 00058 /** Gets the collision_people_element number 00059 * @return collision_people_element 00060 */ 00061 int get_collision_people_element(); 00062 00063 /** Sets alien track_flag 00064 * @param track_flag_ 00065 */ 00066 void set_track_flag(bool track_flag); 00067 00068 /** Gets alien track_flag 00069 * @return track_flag_ 00070 */ 00071 bool get_track_flag(); 00072 00073 private: 00074 // Function prototypes ----------------------------------------------------- 00075 00076 /** Moves the alien towards the spaceship and around the map 00077 * @param spaceship_pos @details : Position of the spaceship 00078 */ 00079 void move_hunt_mode(Vector2D spaceship_pos); 00080 00081 /** Stops the alien from moving off the edge of the map and moves alien 00082 * if the map loops 00083 * @param map_length_@details : length of the map 00084 * @param position_x_map_ @detials : the drawing start posisiton of the 00085 * map 00086 */ 00087 void off_screen_x_y_checker(int map_length_, int position_x_map_); 00088 00089 // Variables --------------------------------------------------------------- 00090 00091 /** Alien movement counter */ 00092 int alien_move_counter_; 00093 00094 /** Alien fire bullet counter */ 00095 int alien_fire_counter_; 00096 00097 /** People element that alien as collided with */ 00098 int collision_people_element_; 00099 00100 /** Alien abducted people and now track spaceship flag */ 00101 bool track_flag_; 00102 00103 }; 00104 00105 #endif
Generated on Fri Aug 5 2022 06:55:07 by
1.7.2