Ben Evans University Second Year Project. Game Called Defender.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Weapons.h Source File

Weapons.h

00001 #ifndef WEAPONS_H
00002 #define WEAPONS_H
00003  
00004 // Included Headers ------------------------------------------------------------
00005 #include "mbed.h"
00006 #include "N5110.h"
00007 #include "Gamepad.h"
00008 #include "RandomMovement.h"
00009 
00010 /** Weapons class
00011  * @brief Draws and moves weapons 
00012  * @author Benjamin Evans, University of Leeds
00013  * @date April 2020
00014  */
00015 class Weapons: public RandomMovement {
00016     public:
00017         /** Constructor */
00018         Weapons();
00019         
00020         /** Destructor */
00021         ~Weapons();
00022         
00023         /** Initialises Weapons 
00024          * @param sprite_pos @details vector 2D of sprite xy position 
00025          * @param sprite_direction @details sprite direction bool, 
00026          * true = E, false = W
00027          * @param bullet_type @details true = spaceship, false = alien
00028          */
00029         void init(Vector2D sprite_pos, bool sprite_direction,bool bullet_type);
00030         
00031         /** Draws the bullet and moves it in x direction each frame
00032          * @param lcd @details N5110 object
00033          */
00034         void draw_bullet(N5110 &lcd);
00035         
00036          /** Draws the aliens bullet and moves it in xy direction each frame
00037          * @param lcd @details N5110 object
00038          * @param d_ @details : Direction object of joystick
00039          */
00040         void draw_alien_bullet(N5110 &lcd, Direction d_);
00041         
00042         /** Tuns lcd back light on and off 
00043          * @param lcd @details N5110 object
00044          */
00045         void smart_bomb(N5110 &lcd);
00046          
00047     // Accessors and mutators --------------------------------------------------
00048         
00049         /** Sets the xy position of the bullet
00050          * @param pos @details vector 2D of bullet xy position 
00051          */
00052         void set_pos_one(Vector2D pos);
00053         
00054         /** Gets the bullet distance counter 
00055          * @return bullet_distance_counter
00056          */
00057         int get_bullet_delete_counter();
00058         
00059         /** Gets the bullet direction
00060          * @return bullet_direction_
00061          */
00062         bool get_direction();
00063         
00064         /** Sets the bullets movement direction when it is fired
00065          * @param spaceship_sprite_direction_ @details sprite direction bool, 
00066          * true = E, false = W
00067          */
00068         void set_direction(bool sprite_direction_);
00069         
00070     private:
00071     // Function prototypes -----------------------------------------------------
00072     
00073         /** Calculates bullets start position
00074          * @param spaceship_pos @details x and y postion of spaceship
00075          * @param spaceship_sprite_direction_ @details sprite direction bool, 
00076          * true = E, false = W
00077          */
00078         void calc_bullets_start_pos(Vector2D spaceship_pos, 
00079         bool spaceship_sprite_direction_);
00080         
00081         /** Calculates alien bullets start position
00082          * @param alien_pos @details x and y postion of spaceship
00083          * @param alien_sprite_direction_ @details sprite direction bool, 
00084          * true = E, false = W
00085          */
00086         void calc_alien_bullets_start_pos(Vector2D alien_pos, 
00087         bool alien_sprite_direction_);
00088     
00089     // Variables ---------------------------------------------------------------
00090         
00091         /** Counter to deleted bullet */
00092         int bullet_delete_counter_; 
00093 };
00094  
00095 #endif