Laila Al Badwawi 200906179 SpaceInvaders I declare this my own independent work and understand the university rules on plagiarism.

Dependencies:   mbed

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?

UserRevisionLine numberNew contents of line
fy14lkaa 28:4786e81ce3e3 1 #ifndef Alien_H
fy14lkaa 28:4786e81ce3e3 2 #define Alien_H
fy14lkaa 28:4786e81ce3e3 3
fy14lkaa 28:4786e81ce3e3 4 #include "mbed.h"
fy14lkaa 28:4786e81ce3e3 5 #include "Gamepad.h"
fy14lkaa 28:4786e81ce3e3 6 #include "N5110.h"
fy14lkaa 133:eed60548d170 7
fy14lkaa 133:eed60548d170 8
fy14lkaa 133:eed60548d170 9 const int alien2[32][32]= {
fy14lkaa 127:8bd8cf136f19 10
fy14lkaa 28:4786e81ce3e3 11
fy14lkaa 133:eed60548d170 12 {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 133:eed60548d170 13 {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 133:eed60548d170 14 {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 133:eed60548d170 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},
fy14lkaa 133:eed60548d170 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},
fy14lkaa 133:eed60548d170 17 {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 133:eed60548d170 18 {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 133:eed60548d170 19 {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 133:eed60548d170 20 {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 133:eed60548d170 21 {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 133:eed60548d170 22 {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},
fy14lkaa 133:eed60548d170 23 {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},
fy14lkaa 133:eed60548d170 24 {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},
fy14lkaa 133:eed60548d170 25 {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},
fy14lkaa 133:eed60548d170 26 {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},
fy14lkaa 133:eed60548d170 27 {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},
fy14lkaa 133:eed60548d170 28 {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 133:eed60548d170 29 {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 133:eed60548d170 30 {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},
fy14lkaa 133:eed60548d170 31 {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},
fy14lkaa 133:eed60548d170 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},
fy14lkaa 133:eed60548d170 33 {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},
fy14lkaa 133:eed60548d170 34 {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 133:eed60548d170 35 {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},
fy14lkaa 133:eed60548d170 36 {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 133:eed60548d170 37 {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 133:eed60548d170 38 {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 133:eed60548d170 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},
fy14lkaa 133:eed60548d170 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},
fy14lkaa 133:eed60548d170 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},
fy14lkaa 133:eed60548d170 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},
fy14lkaa 133:eed60548d170 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},
fy14lkaa 133:eed60548d170 44 };
fy14lkaa 133:eed60548d170 45
fy14lkaa 133:eed60548d170 46 /** Alien class
fy14lkaa 133:eed60548d170 47 @brief class for Alien
fy14lkaa 133:eed60548d170 48 @version 1.0
fy14lkaa 133:eed60548d170 49 @author Laila Al Badwawi
fy14lkaa 133:eed60548d170 50 @date April 2019
fy14lkaa 133:eed60548d170 51 */
fy14lkaa 28:4786e81ce3e3 52 class Alien
fy14lkaa 28:4786e81ce3e3 53 {
fy14lkaa 95:1b43f9c332bc 54 public:
fy14lkaa 149:bd0f37008f5a 55 Alien(); // constructor
fy14lkaa 149:bd0f37008f5a 56 ~Alien(); // destructor
fy14lkaa 95:1b43f9c332bc 57
fy14lkaa 133:eed60548d170 58 /**
fy14lkaa 133:eed60548d170 59 *@brief initialise an identity for the Alien
fy14lkaa 133:eed60548d170 60 *@param x_alien @details the x-cooridante of Alien in intger
fy14lkaa 133:eed60548d170 61 *@param y_alien @details the y-cooridante of Alien in integer
fy14lkaa 133:eed60548d170 62 *@param speed_alien @details the speed of Alien in integer
fy14lkaa 133:eed60548d170 63 */
fy14lkaa 95:1b43f9c332bc 64
fy14lkaa 95:1b43f9c332bc 65 void init(int x_alien,int y_alien, int speed_alien);
fy14lkaa 133:eed60548d170 66 /**
fy14lkaa 143:171bd2687a03 67 *@brief drawing the alien in the lcd
fy14lkaa 137:fe80c0f2da9d 68 *@param _(N5110 &lcd)@details the libraries which draw the alien in class Alien.
fy14lkaa 133:eed60548d170 69 */
fy14lkaa 28:4786e81ce3e3 70 void draw(N5110 &lcd);
fy14lkaa 133:eed60548d170 71 /**
fy14lkaa 137:fe80c0f2da9d 72 *@brief updating the direction and the magintuide of the alien
fy14lkaa 137:fe80c0f2da9d 73 *@param_(Direction d,float mag)@details update the direction and the magintuide of the alien.
fy14lkaa 137:fe80c0f2da9d 74 **/
fy14lkaa 95:1b43f9c332bc 75 void update(Direction d,float mag);
fy14lkaa 133:eed60548d170 76
fy14lkaa 137:fe80c0f2da9d 77 /**@brief sitting up the position the of the alien
fy14lkaa 149:bd0f37008f5a 78 *@param _(x,y) @details set the position the of the alien in x-cooridante and y-cooridante
fy14lkaa 137:fe80c0f2da9d 79 */
fy14lkaa 133:eed60548d170 80 void set_pos(int x, int y);
fy14lkaa 137:fe80c0f2da9d 81 /**@brief Gets the postion of the y-cooridante
fy14lkaa 137:fe80c0f2da9d 82 *@returns the position of the y-cooridante in integer which refer to the alien
fy14lkaa 137:fe80c0f2da9d 83 */
fy14lkaa 133:eed60548d170 84 int get_pos_y();
fy14lkaa 137:fe80c0f2da9d 85 /**@brief Gets the postion of the x-cooridante
fy14lkaa 137:fe80c0f2da9d 86 *@returns the position of the x-cooridante in integer which refer to the alien
fy14lkaa 137:fe80c0f2da9d 87 */
fy14lkaa 133:eed60548d170 88 int get_pos_x();
fy14lkaa 137:fe80c0f2da9d 89 /**
fy14lkaa 137:fe80c0f2da9d 90 *@brief adding scores of the Alien
fy14lkaa 137:fe80c0f2da9d 91 *@param _scores @details adding scores when alien fired the spaceship back.
fy14lkaa 137:fe80c0f2da9d 92 */
fy14lkaa 133:eed60548d170 93 void add_score();
fy14lkaa 137:fe80c0f2da9d 94 /**@brief Gets the scores of the Alien
fy14lkaa 137:fe80c0f2da9d 95 *@returns the number of the scores of the alien in integer
fy14lkaa 137:fe80c0f2da9d 96 */
fy14lkaa 133:eed60548d170 97 int get_score();
fy14lkaa 137:fe80c0f2da9d 98 /**
fy14lkaa 143:171bd2687a03 99 *@brief reading the position of the alien
fy14lkaa 137:fe80c0f2da9d 100 *@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.
fy14lkaa 137:fe80c0f2da9d 101 */
fy14lkaa 133:eed60548d170 102 void read_input(Gamepad &pad);
fy14lkaa 137:fe80c0f2da9d 103 /**@brief Gets the alive Alien
fy14lkaa 137:fe80c0f2da9d 104 *@returns alive alien in bool
fy14lkaa 137:fe80c0f2da9d 105 */
fy14lkaa 133:eed60548d170 106 bool isAlive();
fy14lkaa 137:fe80c0f2da9d 107 /**@brief sitting the alive Alien
fy14lkaa 137:fe80c0f2da9d 108 *@param alive @details set the positions of the alive alien in class Alien
fy14lkaa 137:fe80c0f2da9d 109 */
fy14lkaa 133:eed60548d170 110 void setAlive(bool alive);
fy14lkaa 133:eed60548d170 111
fy14lkaa 92:8a1b14488ca5 112
fy14lkaa 28:4786e81ce3e3 113 private:
fy14lkaa 149:bd0f37008f5a 114
fy14lkaa 92:8a1b14488ca5 115
fy14lkaa 143:171bd2687a03 116 /**
fy14lkaa 133:eed60548d170 117 *@param (_x_alien) a private variable of class Alien that represents the x-cooridante of the alien
fy14lkaa 133:eed60548d170 118 */
fy14lkaa 95:1b43f9c332bc 119 int _x_alien;
fy14lkaa 133:eed60548d170 120
fy14lkaa 143:171bd2687a03 121 /**
fy14lkaa 137:fe80c0f2da9d 122 *@param (_y_alien)a private variable of class Alien that represents the y-cooridante of the alien
fy14lkaa 133:eed60548d170 123 */
fy14lkaa 133:eed60548d170 124
fy14lkaa 95:1b43f9c332bc 125 int _y_alien;
fy14lkaa 143:171bd2687a03 126 /**
fy14lkaa 143:171bd2687a03 127 *@param (_alien2)a private variable of class Alien used for drawing the alien in sprite.
fy14lkaa 137:fe80c0f2da9d 128 */
fy14lkaa 133:eed60548d170 129 int _alien2;
fy14lkaa 143:171bd2687a03 130 /**
fy14lkaa 133:eed60548d170 131 *@param (_speed_alien)a private variable of class Alien that represents the speed of the alien
fy14lkaa 137:fe80c0f2da9d 132
fy14lkaa 133:eed60548d170 133 */
fy14lkaa 95:1b43f9c332bc 134 int _speed_alien;
fy14lkaa 133:eed60548d170 135
fy14lkaa 143:171bd2687a03 136 /**
fy14lkaa 149:bd0f37008f5a 137 *@param (_score) a private variable of class Alien that represent the scores was achived by alien
fy14lkaa 143:171bd2687a03 138 */
fy14lkaa 133:eed60548d170 139 int _score;
fy14lkaa 133:eed60548d170 140
fy14lkaa 143:171bd2687a03 141 /**
fy14lkaa 143:171bd2687a03 142 @param(_alive) a private variable of class Alien that represents the Alive alien
fy14lkaa 143:171bd2687a03 143 */
fy14lkaa 133:eed60548d170 144 bool _alive;
fy14lkaa 137:fe80c0f2da9d 145
fy14lkaa 143:171bd2687a03 146 /**
fy14lkaa 149:bd0f37008f5a 147 *@param(_direcation) a private variable of class Alien that represents the direction of the alien
fy14lkaa 143:171bd2687a03 148 */
fy14lkaa 95:1b43f9c332bc 149 Direction d;
fy14lkaa 137:fe80c0f2da9d 150
fy14lkaa 143:171bd2687a03 151 /**
fy14lkaa 143:171bd2687a03 152 *@param(_mag) float a private variable of class Alien that represents magnitude of the alien
fy14lkaa 143:171bd2687a03 153 */
fy14lkaa 95:1b43f9c332bc 154 float mag;
fy14lkaa 28:4786e81ce3e3 155 };
fy14lkaa 28:4786e81ce3e3 156 #endif