ELEC2645 (2018/19) / Mbed 2 deprecated fy14lkaa

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Alien.h Source File

Alien.h

00001 #ifndef Alien_H
00002 #define Alien_H
00003 
00004 #include "mbed.h"
00005 #include "Gamepad.h"
00006 #include "N5110.h"
00007 
00008 
00009 const int alien2[32][32]= {
00010 
00011 
00012     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00013     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00014     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00015     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00016     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00017     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00018     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00019     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00020     {0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00021     {0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00022     {0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0},
00023     {0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0},
00024     {0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0},
00025     {0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0},
00026     {1,1,1,1,0,0,0,1,1,1,1,0,0,0,1,1,1,1,0,0,0,0,0,0,0},
00027     {0,1,1,1,0,0,0,1,1,1,1,0,0,0,1,1,1,1,0,0,0,0,0,0,0},
00028     {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0},
00029     {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0},
00030     {0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0},
00031     {0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0},
00032     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00033     {0,0,0,1,0,0,0,1,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0},
00034     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00035     {1,1,0,0,0,1,1,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0},
00036     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00037     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00038     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00039     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00040     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00041     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00042     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00043     {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
00044 };
00045 
00046 /** Alien class
00047 @brief class for Alien
00048 @version 1.0
00049 @author Laila Al Badwawi
00050 @date April 2019
00051 */
00052 class Alien
00053 {
00054 public:
00055     Alien();  // constructor
00056     ~Alien(); // destructor
00057 
00058     /**
00059       *@brief initialise an identity for the Alien
00060       *@param x_alien @details the x-cooridante of Alien in intger
00061       *@param y_alien @details the y-cooridante of Alien in integer
00062       *@param speed_alien @details the speed of Alien in integer
00063       */
00064 
00065     void init(int x_alien,int y_alien, int speed_alien);
00066     /**
00067     *@brief drawing the alien in the lcd
00068     *@param _(N5110 &lcd)@details the libraries which draw the alien in class Alien.
00069     */
00070     void draw(N5110 &lcd);
00071     /**
00072     *@brief updating the direction and the magintuide of the alien
00073     *@param_(Direction d,float mag)@details update the direction and the magintuide of the alien.
00074     **/
00075     void update(Direction d,float mag);
00076 
00077     /**@brief sitting up the position the of the alien
00078     *@param _(x,y) @details set the position the of the alien in x-cooridante and y-cooridante
00079     */
00080     void set_pos(int x, int y);
00081     /**@brief Gets the postion of the y-cooridante
00082        *@returns the position of the y-cooridante in integer which refer to the alien
00083        */
00084     int  get_pos_y();
00085     /**@brief Gets the postion of the x-cooridante
00086     *@returns the position of the x-cooridante in integer which refer to the alien
00087     */
00088     int  get_pos_x();
00089     /**
00090     *@brief adding scores of the Alien
00091     *@param _scores @details adding scores when alien fired the spaceship back.
00092     */
00093     void add_score();
00094     /**@brief Gets the scores  of the Alien
00095     *@returns the number of the scores of the alien in integer
00096     */
00097     int get_score();
00098     /**
00099     *@brief reading the position of the alien
00100     *@param _(Gamepad and pad)@details the libraries which reading the position of the alien in class Alien to detect the collisions between it and the other objects.
00101     */
00102     void read_input(Gamepad &pad);
00103     /**@brief Gets the alive Alien
00104     *@returns alive alien in bool
00105     */
00106     bool isAlive();
00107     /**@brief sitting the alive Alien
00108     *@param alive @details set the positions of the alive alien in class Alien
00109     */
00110     void setAlive(bool alive);
00111 
00112 
00113 private:
00114    
00115 
00116     /**
00117     *@param (_x_alien) a private variable of class Alien that represents the x-cooridante of the alien
00118      */
00119     int _x_alien;
00120 
00121     /**
00122     *@param (_y_alien)a private variable of class Alien that represents the y-cooridante of the alien
00123     */
00124 
00125     int _y_alien;
00126     /**
00127     *@param (_alien2)a private variable of class Alien used for drawing the alien in sprite.
00128     */
00129     int _alien2;
00130     /**
00131     *@param (_speed_alien)a private variable of class Alien that represents the speed of the alien
00132 
00133     */
00134     int _speed_alien;
00135 
00136     /**
00137      *@param  (_score) a private variable of class Alien that represent the scores was achived by alien
00138     */
00139     int _score;
00140 
00141     /**
00142      @param(_alive)  a private variable of class Alien that represents the Alive alien
00143      */
00144     bool _alive;
00145 
00146     /**
00147     *@param(_direcation) a private variable of class Alien that represents the direction of the alien
00148     */
00149     Direction d;
00150 
00151     /**
00152      *@param(_mag) float a private variable of class Alien that represents magnitude of the  alien
00153      */
00154     float mag;
00155 };
00156 #endif