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 08:23:15 2019 +0000
Revision:
143:171bd2687a03
Parent:
137:fe80c0f2da9d
Child:
145:e060e890c725
added more comments on bullet.cpp

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