Laila Al Badwawi 200906179 SpaceInvaders I declare this my own independent work and understand the university rules on plagiarism.
Dependencies: mbed
Spaceship/Spaceship.h@150:bd02678bfdb1, 2019-05-09 (annotated)
- Committer:
- fy14lkaa
- Date:
- Thu May 09 14:23:44 2019 +0000
- Revision:
- 150:bd02678bfdb1
- Parent:
- 149:bd0f37008f5a
finished the games and the last formatting
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fy14lkaa | 138:66befaefb27e | 1 | |
fy14lkaa | 138:66befaefb27e | 2 | #ifndef SPACESHIP_H |
fy14lkaa | 138:66befaefb27e | 3 | #define SPACESHIP_H |
fy14lkaa | 138:66befaefb27e | 4 | |
fy14lkaa | 138:66befaefb27e | 5 | #include "mbed.h" |
fy14lkaa | 138:66befaefb27e | 6 | #include "N5110.h" |
fy14lkaa | 138:66befaefb27e | 7 | #include "Gamepad.h" |
fy14lkaa | 138:66befaefb27e | 8 | #include "Alien.h" |
fy14lkaa | 138:66befaefb27e | 9 | #include "Bullet.h" |
fy14lkaa | 138:66befaefb27e | 10 | |
fy14lkaa | 138:66befaefb27e | 11 | |
fy14lkaa | 138:66befaefb27e | 12 | |
fy14lkaa | 138:66befaefb27e | 13 | |
fy14lkaa | 138:66befaefb27e | 14 | const int spaceship2[32][32]= { |
fy14lkaa | 138:66befaefb27e | 15 | {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}, |
fy14lkaa | 138:66befaefb27e | 16 | {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}, |
fy14lkaa | 138:66befaefb27e | 17 | {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}, |
fy14lkaa | 138:66befaefb27e | 18 | {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}, |
fy14lkaa | 138:66befaefb27e | 19 | {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}, |
fy14lkaa | 138:66befaefb27e | 20 | {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}, |
fy14lkaa | 138:66befaefb27e | 21 | {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}, |
fy14lkaa | 138:66befaefb27e | 22 | {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}, |
fy14lkaa | 138:66befaefb27e | 23 | {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}, |
fy14lkaa | 138:66befaefb27e | 24 | {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}, |
fy14lkaa | 138:66befaefb27e | 25 | {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,0,0,0}, |
fy14lkaa | 138:66befaefb27e | 26 | {0,1,1,1,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,0}, |
fy14lkaa | 138:66befaefb27e | 27 | {1,1,1,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,1,1,1}, |
fy14lkaa | 138:66befaefb27e | 28 | {0,1,1,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,1,1,1,0}, |
fy14lkaa | 138:66befaefb27e | 29 | {0,0,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,1,0,0}, |
fy14lkaa | 138:66befaefb27e | 30 | {0,0,0,1,1,1,1,1,1,0,1,1,1,1,0,0,0,1,1,1,1,0,1,1,1,1,1,1,1,0,0,0}, |
fy14lkaa | 138:66befaefb27e | 31 | {0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0}, |
fy14lkaa | 138:66befaefb27e | 32 | {0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0}, |
fy14lkaa | 138:66befaefb27e | 33 | {0,0,0,0,0,0,0,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}, |
fy14lkaa | 138:66befaefb27e | 34 | {0,0,0,0,0,0,0,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}, |
fy14lkaa | 138:66befaefb27e | 35 | {0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0}, |
fy14lkaa | 138:66befaefb27e | 36 | {0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0}, |
fy14lkaa | 138:66befaefb27e | 37 | {0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0}, |
fy14lkaa | 138:66befaefb27e | 38 | {0,0,0,0,0,0,0,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}, |
fy14lkaa | 138:66befaefb27e | 39 | {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}, |
fy14lkaa | 138:66befaefb27e | 40 | {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}, |
fy14lkaa | 138:66befaefb27e | 41 | {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}, |
fy14lkaa | 138:66befaefb27e | 42 | {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}, |
fy14lkaa | 138:66befaefb27e | 43 | {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}, |
fy14lkaa | 138:66befaefb27e | 44 | }; |
fy14lkaa | 138:66befaefb27e | 45 | |
fy14lkaa | 138:66befaefb27e | 46 | |
fy14lkaa | 138:66befaefb27e | 47 | |
fy14lkaa | 138:66befaefb27e | 48 | /** Spaceship class |
fy14lkaa | 138:66befaefb27e | 49 | @brief class for spaceship |
fy14lkaa | 138:66befaefb27e | 50 | @version 1.0 |
fy14lkaa | 138:66befaefb27e | 51 | @author Laila Al Badwawi |
fy14lkaa | 138:66befaefb27e | 52 | @date April 2019 |
fy14lkaa | 138:66befaefb27e | 53 | */ |
fy14lkaa | 138:66befaefb27e | 54 | |
fy14lkaa | 138:66befaefb27e | 55 | class Spaceship |
fy14lkaa | 138:66befaefb27e | 56 | { |
fy14lkaa | 138:66befaefb27e | 57 | |
fy14lkaa | 138:66befaefb27e | 58 | public: |
fy14lkaa | 138:66befaefb27e | 59 | |
fy14lkaa | 149:bd0f37008f5a | 60 | |
fy14lkaa | 138:66befaefb27e | 61 | |
fy14lkaa | 149:bd0f37008f5a | 62 | |
fy14lkaa | 149:bd0f37008f5a | 63 | Spaceship(); // constructor |
fy14lkaa | 149:bd0f37008f5a | 64 | ~Spaceship(); // destructor |
fy14lkaa | 138:66befaefb27e | 65 | /** |
fy14lkaa | 145:e060e890c725 | 66 | *@brief initialise an identity for the spaceship |
fy14lkaa | 145:e060e890c725 | 67 | *@param x_spaceship @details the x-cooridante of spaceship in intger |
fy14lkaa | 145:e060e890c725 | 68 | *@param y_spaceship @details the y-cooridante of spaceship in integer |
fy14lkaa | 145:e060e890c725 | 69 | *@param speed_spaceship @details the speed of spaceship in integer |
fy14lkaa | 145:e060e890c725 | 70 | */ |
fy14lkaa | 138:66befaefb27e | 71 | |
fy14lkaa | 138:66befaefb27e | 72 | |
fy14lkaa | 138:66befaefb27e | 73 | void init(int x_spaceship,int y_spaceship, int speed_spaceship); |
fy14lkaa | 138:66befaefb27e | 74 | |
fy14lkaa | 138:66befaefb27e | 75 | /** |
fy14lkaa | 138:66befaefb27e | 76 | *@brief drawing the spaceship |
fy14lkaa | 149:bd0f37008f5a | 77 | *@param _(N5110 &lcd)@details the libraries which draw the spaceship on the screen. |
fy14lkaa | 138:66befaefb27e | 78 | */ |
fy14lkaa | 138:66befaefb27e | 79 | void draw(N5110 &lcd); |
fy14lkaa | 138:66befaefb27e | 80 | /** |
fy14lkaa | 149:bd0f37008f5a | 81 | *@brief updating the direction and the magintuide of the spaceship |
fy14lkaa | 149:bd0f37008f5a | 82 | *@param_(Direction d,float mag)@details update the direction and the magintuide of the spaceship. |
fy14lkaa | 149:bd0f37008f5a | 83 | **/ |
fy14lkaa | 138:66befaefb27e | 84 | void update(Direction d,float mag); |
fy14lkaa | 149:bd0f37008f5a | 85 | /**@brief setting up the position the of the spaceship |
fy14lkaa | 149:bd0f37008f5a | 86 | *@param _(x,y) @details set the position the of the spaceship in x-cooridante and y-cooridante |
fy14lkaa | 138:66befaefb27e | 87 | */ |
fy14lkaa | 138:66befaefb27e | 88 | void set_pos(int x, int y); |
fy14lkaa | 144:0473845a4aaa | 89 | /** |
fy14lkaa | 144:0473845a4aaa | 90 | *@brief Gets the postion of the y-cooridante |
fy14lkaa | 144:0473845a4aaa | 91 | *@returns the position of the y-cooridante in integer which refer to the spaceship |
fy14lkaa | 144:0473845a4aaa | 92 | */ |
fy14lkaa | 138:66befaefb27e | 93 | int get_pos_y(); |
fy14lkaa | 145:e060e890c725 | 94 | /** |
fy14lkaa | 145:e060e890c725 | 95 | *@brief Gets the postion of the x-cooridante |
fy14lkaa | 145:e060e890c725 | 96 | *@returns the position of the x-cooridante in integer which refer to the spaceship |
fy14lkaa | 145:e060e890c725 | 97 | */ |
fy14lkaa | 138:66befaefb27e | 98 | int get_pos_x(); |
fy14lkaa | 145:e060e890c725 | 99 | /** |
fy14lkaa | 145:e060e890c725 | 100 | *@brief reading the position of the spaceship |
fy14lkaa | 145:e060e890c725 | 101 | *@param _(Gamepad and pad)@details the libraries which reading the position of the spaceship in class Spaceship to detect the collisions between it and the other objects. |
fy14lkaa | 145:e060e890c725 | 102 | */ |
fy14lkaa | 138:66befaefb27e | 103 | void read_input(Gamepad &pad); |
fy14lkaa | 145:e060e890c725 | 104 | /** |
fy14lkaa | 145:e060e890c725 | 105 | *@brief adding scores of the spaceship |
fy14lkaa | 145:e060e890c725 | 106 | *@param _scores @details adding scores when spaceship fired the alien. |
fy14lkaa | 145:e060e890c725 | 107 | */ |
fy14lkaa | 138:66befaefb27e | 108 | void add_score(); |
fy14lkaa | 145:e060e890c725 | 109 | /** |
fy14lkaa | 145:e060e890c725 | 110 | *@brief Gets the scores of the spaceship |
fy14lkaa | 145:e060e890c725 | 111 | *@returns the number of the scores of the spaceship in integer |
fy14lkaa | 145:e060e890c725 | 112 | */ |
fy14lkaa | 138:66befaefb27e | 113 | int get_score(); |
fy14lkaa | 138:66befaefb27e | 114 | |
fy14lkaa | 138:66befaefb27e | 115 | |
fy14lkaa | 138:66befaefb27e | 116 | private: |
fy14lkaa | 138:66befaefb27e | 117 | |
fy14lkaa | 145:e060e890c725 | 118 | /** |
fy14lkaa | 138:66befaefb27e | 119 | *@param (_x_spaceship) a private variable of class Spaceship that represents the x-cooridante of the spaceship |
fy14lkaa | 145:e060e890c725 | 120 | */ |
fy14lkaa | 138:66befaefb27e | 121 | int _x_spaceship; |
fy14lkaa | 145:e060e890c725 | 122 | /** |
fy14lkaa | 138:66befaefb27e | 123 | *@param (_x_spaceship) a private variable of class spaceship that represents the x-cooridante of the spaceship |
fy14lkaa | 138:66befaefb27e | 124 | */ |
fy14lkaa | 138:66befaefb27e | 125 | int _y_spaceship; |
fy14lkaa | 138:66befaefb27e | 126 | |
fy14lkaa | 145:e060e890c725 | 127 | /** |
fy14lkaa | 138:66befaefb27e | 128 | *@param (_speed_spaceship) declation of a variable private member which shows the speed of the spaceship. |
fy14lkaa | 138:66befaefb27e | 129 | */ |
fy14lkaa | 138:66befaefb27e | 130 | |
fy14lkaa | 138:66befaefb27e | 131 | int _speed_spaceship; |
fy14lkaa | 138:66befaefb27e | 132 | |
fy14lkaa | 145:e060e890c725 | 133 | /** |
fy14lkaa | 145:e060e890c725 | 134 | *@param (_spaceship2)a private variable of class Spaceship used for drawing the spaceship in sprite. |
fy14lkaa | 145:e060e890c725 | 135 | */ |
fy14lkaa | 138:66befaefb27e | 136 | int _spaceship2; |
fy14lkaa | 145:e060e890c725 | 137 | /** |
fy14lkaa | 145:e060e890c725 | 138 | *@param (_score) a private variable of class Spaceship that represent the scores of the spaceship. |
fy14lkaa | 145:e060e890c725 | 139 | */ |
fy14lkaa | 138:66befaefb27e | 140 | int _score; |
fy14lkaa | 138:66befaefb27e | 141 | |
fy14lkaa | 145:e060e890c725 | 142 | /** |
fy14lkaa | 149:bd0f37008f5a | 143 | *@param(_direcation) a private variable of class spaceship that represents the direction of spaceship |
fy14lkaa | 145:e060e890c725 | 144 | */ |
fy14lkaa | 138:66befaefb27e | 145 | Direction d; |
fy14lkaa | 149:bd0f37008f5a | 146 | /** |
fy14lkaa | 149:bd0f37008f5a | 147 | *@param(_mag) float a private variable of class spaceship that represents magnitude of the spaceship |
fy14lkaa | 145:e060e890c725 | 148 | */ |
fy14lkaa | 138:66befaefb27e | 149 | float mag; |
fy14lkaa | 138:66befaefb27e | 150 | }; |
fy14lkaa | 138:66befaefb27e | 151 | #endif |