Laila Al Badwawi 200906179 SpaceInvaders I declare this my own independent work and understand the university rules on plagiarism.
Dependencies: mbed
Diff: Spaceship/Spaceship.h
- Revision:
- 138:66befaefb27e
- Child:
- 144:0473845a4aaa
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Spaceship/Spaceship.h Thu May 09 05:42:22 2019 +0000 @@ -0,0 +1,135 @@ + +#ifndef SPACESHIP_H +#define SPACESHIP_H + +#include "mbed.h" +#include "N5110.h" +#include "Gamepad.h" +#include "Alien.h" +#include "Bullet.h" + + + + +const int spaceship2[32][32]= { + {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,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,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,0,0,0,1,1,1,1,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,0,1,0,0,1,1,1,1,1,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,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,1,1,0,0,0,0,0,0}, + {0,0,0,0,1,1,1,1,0,0,1,0,0,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1,0,0,0,0}, + {0,0,1,1,1,1,1,1,1,0,0,1,0,0,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, +}; + + + +/** Spaceship class +@brief class for spaceship +@version 1.0 +@author Laila Al Badwawi +@date April 2019 +*/ + +class Spaceship +{ + +public: + + /** constructors + *string Variables of this type are able to store sequences of characters, + *such as words or sentences. + */ + + + /*@constucter creat a defult a Spaceship + */ + + Spaceship(); + + /** + *@constucter creat a defult a spaceship + */ + ~Spaceship(); + /** + *@brief initialise an identity for the spaceship + *@param x_spaceship @details the x-cooridante of spaceship in intger + *@param y_spaceship @details the y-cooridante of spaceship in integer + *@param speed_spaceship @details the speed of spaceship in integer + */ + + + void init(int x_spaceship,int y_spaceship, int speed_spaceship); + + /** + *@brief drawing the spaceship + *@param draw @details drawing the spaceship by using N5110&lcd librarieas + */ + void draw(N5110 &lcd); + /** + *@brief updating the position of the spaceship + *@param update @details update the position of the spaceship. + */ + void update(Direction d,float mag); + /**@brief sitting up the position the of the spaceship + *@param set_pos @details set the position the of the spaceship in x-cooridante and y-cooridante + */ + void set_pos(int x, int y); + int get_pos_y(); + int get_pos_x(); + void read_input(Gamepad &pad); + void add_score(); + int get_score(); + + +private: + + /* + *@param (_x_spaceship) a private variable of class Spaceship that represents the x-cooridante of the spaceship + */ + int _x_spaceship; + /* + *@param (_x_spaceship) a private variable of class spaceship that represents the x-cooridante of the spaceship + */ + int _y_spaceship; + + /* + *@param (_speed_spaceship) declation of a variable private member which shows the speed of the spaceship. + */ + + int _speed_spaceship; + + int _spaceship2; + int _score; + + /*@param + (_direcation) a private variable of class spaceship that represents of spaceship + */ + Direction d; + /*@param + (_mag) float a private variable of class spaceship that represents magnitude of the spaceship + */ + float mag; +}; +#endif \ No newline at end of file