Hu Dongyu
/
HuDongyu
publish my project
Start/Start.cpp@0:9e95a5ef2659, 2020-04-27 (annotated)
- Committer:
- dongyuhu
- Date:
- Mon Apr 27 06:14:34 2020 +0000
- Revision:
- 0:9e95a5ef2659
- Child:
- 3:c89450845b2a
initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dongyuhu | 0:9e95a5ef2659 | 1 | #include "Start.h" |
dongyuhu | 0:9e95a5ef2659 | 2 | bool ifnotstop = true; |
dongyuhu | 0:9e95a5ef2659 | 3 | |
dongyuhu | 0:9e95a5ef2659 | 4 | Start::Start() |
dongyuhu | 0:9e95a5ef2659 | 5 | { |
dongyuhu | 0:9e95a5ef2659 | 6 | |
dongyuhu | 0:9e95a5ef2659 | 7 | } |
dongyuhu | 0:9e95a5ef2659 | 8 | |
dongyuhu | 0:9e95a5ef2659 | 9 | Start::~Start() |
dongyuhu | 0:9e95a5ef2659 | 10 | { |
dongyuhu | 0:9e95a5ef2659 | 11 | |
dongyuhu | 0:9e95a5ef2659 | 12 | } |
dongyuhu | 0:9e95a5ef2659 | 13 | |
dongyuhu | 0:9e95a5ef2659 | 14 | void Start::init(int me_width,int me_height,int attacker_size,int speed) |
dongyuhu | 0:9e95a5ef2659 | 15 | { |
dongyuhu | 0:9e95a5ef2659 | 16 | // initialise the game parameters |
dongyuhu | 0:9e95a5ef2659 | 17 | _me_width = me_width; //3 |
dongyuhu | 0:9e95a5ef2659 | 18 | _me_height = me_height; //3 |
dongyuhu | 0:9e95a5ef2659 | 19 | _attacker_size = attacker_size; //2 |
dongyuhu | 0:9e95a5ef2659 | 20 | _speed = speed; //1 |
dongyuhu | 0:9e95a5ef2659 | 21 | |
dongyuhu | 0:9e95a5ef2659 | 22 | |
dongyuhu | 0:9e95a5ef2659 | 23 | |
dongyuhu | 0:9e95a5ef2659 | 24 | _me.init(_mex,_mey,_me_height,_me_width); |
dongyuhu | 0:9e95a5ef2659 | 25 | |
dongyuhu | 0:9e95a5ef2659 | 26 | _attacker1.init1(_attacker_size,_speed); |
dongyuhu | 0:9e95a5ef2659 | 27 | _attacker2.init2(_attacker_size,_speed); |
dongyuhu | 0:9e95a5ef2659 | 28 | _attacker3.init3(_attacker_size,_speed); |
dongyuhu | 0:9e95a5ef2659 | 29 | _attacker4.init4(_attacker_size,_speed); |
dongyuhu | 0:9e95a5ef2659 | 30 | _attacker5.init5(_attacker_size,_speed); |
dongyuhu | 0:9e95a5ef2659 | 31 | _attacker6.init6(_attacker_size,_speed); |
dongyuhu | 0:9e95a5ef2659 | 32 | _attacker7.init7(_attacker_size,_speed); |
dongyuhu | 0:9e95a5ef2659 | 33 | _attacker8.init8(_attacker_size,_speed); |
dongyuhu | 0:9e95a5ef2659 | 34 | |
dongyuhu | 0:9e95a5ef2659 | 35 | } |
dongyuhu | 0:9e95a5ef2659 | 36 | |
dongyuhu | 0:9e95a5ef2659 | 37 | void Start::read_input(Gamepad &pad) |
dongyuhu | 0:9e95a5ef2659 | 38 | { |
dongyuhu | 0:9e95a5ef2659 | 39 | _d = pad.get_direction(); |
dongyuhu | 0:9e95a5ef2659 | 40 | _mag = pad.get_mag(); |
dongyuhu | 0:9e95a5ef2659 | 41 | } |
dongyuhu | 0:9e95a5ef2659 | 42 | |
dongyuhu | 0:9e95a5ef2659 | 43 | void Start::draw(N5110 &lcd) |
dongyuhu | 0:9e95a5ef2659 | 44 | { |
dongyuhu | 0:9e95a5ef2659 | 45 | |
dongyuhu | 0:9e95a5ef2659 | 46 | lcd.drawRect(0,0,WIDTH,HEIGHT,FILL_TRANSPARENT); //draw the turrets |
dongyuhu | 0:9e95a5ef2659 | 47 | lcd.drawRect(10,10,64,28,FILL_TRANSPARENT); //map |
dongyuhu | 0:9e95a5ef2659 | 48 | lcd.drawCircle(5,17,4,FILL_TRANSPARENT); |
dongyuhu | 0:9e95a5ef2659 | 49 | lcd.drawCircle(5,31,4,FILL_TRANSPARENT); //the two in left |
dongyuhu | 0:9e95a5ef2659 | 50 | lcd.drawCircle(78,17,4,FILL_TRANSPARENT); |
dongyuhu | 0:9e95a5ef2659 | 51 | lcd.drawCircle(78,31,4,FILL_TRANSPARENT); //right |
dongyuhu | 0:9e95a5ef2659 | 52 | lcd.drawCircle(30,5,4,FILL_TRANSPARENT); |
dongyuhu | 0:9e95a5ef2659 | 53 | lcd.drawCircle(54,5,4,FILL_TRANSPARENT); //up |
dongyuhu | 0:9e95a5ef2659 | 54 | lcd.drawCircle(30,42,4,FILL_TRANSPARENT); |
dongyuhu | 0:9e95a5ef2659 | 55 | lcd.drawCircle(54,42,4,FILL_TRANSPARENT); //down |
dongyuhu | 0:9e95a5ef2659 | 56 | |
dongyuhu | 0:9e95a5ef2659 | 57 | _me.draw(lcd); |
dongyuhu | 0:9e95a5ef2659 | 58 | _attacker1.draw(lcd); |
dongyuhu | 0:9e95a5ef2659 | 59 | _attacker2.draw(lcd); |
dongyuhu | 0:9e95a5ef2659 | 60 | _attacker3.draw(lcd); |
dongyuhu | 0:9e95a5ef2659 | 61 | _attacker4.draw(lcd); |
dongyuhu | 0:9e95a5ef2659 | 62 | _attacker5.draw(lcd); |
dongyuhu | 0:9e95a5ef2659 | 63 | _attacker6.draw(lcd); |
dongyuhu | 0:9e95a5ef2659 | 64 | _attacker7.draw(lcd); |
dongyuhu | 0:9e95a5ef2659 | 65 | _attacker8.draw(lcd); |
dongyuhu | 0:9e95a5ef2659 | 66 | |
dongyuhu | 0:9e95a5ef2659 | 67 | } |
dongyuhu | 0:9e95a5ef2659 | 68 | |
dongyuhu | 0:9e95a5ef2659 | 69 | void Start::update(Gamepad &pad) |
dongyuhu | 0:9e95a5ef2659 | 70 | { |
dongyuhu | 0:9e95a5ef2659 | 71 | _me.update(_d); |
dongyuhu | 0:9e95a5ef2659 | 72 | _attacker1.update(); |
dongyuhu | 0:9e95a5ef2659 | 73 | _attacker2.update(); |
dongyuhu | 0:9e95a5ef2659 | 74 | _attacker3.update(); |
dongyuhu | 0:9e95a5ef2659 | 75 | _attacker4.update(); |
dongyuhu | 0:9e95a5ef2659 | 76 | _attacker5.update(); |
dongyuhu | 0:9e95a5ef2659 | 77 | _attacker6.update(); |
dongyuhu | 0:9e95a5ef2659 | 78 | _attacker7.update(); |
dongyuhu | 0:9e95a5ef2659 | 79 | _attacker8.update(); |
dongyuhu | 0:9e95a5ef2659 | 80 | |
dongyuhu | 0:9e95a5ef2659 | 81 | check_wall_collision(pad); |
dongyuhu | 0:9e95a5ef2659 | 82 | check_body_collisions(pad); |
dongyuhu | 0:9e95a5ef2659 | 83 | |
dongyuhu | 0:9e95a5ef2659 | 84 | } |
dongyuhu | 0:9e95a5ef2659 | 85 | |
dongyuhu | 0:9e95a5ef2659 | 86 | void Start::check_wall_collision(Gamepad &pad) |
dongyuhu | 0:9e95a5ef2659 | 87 | { |
dongyuhu | 0:9e95a5ef2659 | 88 | Vector2D attacker11_pos = _attacker1.get_pos(); |
dongyuhu | 0:9e95a5ef2659 | 89 | Vector2D attacker22_pos = _attacker2.get_pos(); |
dongyuhu | 0:9e95a5ef2659 | 90 | Vector2D attacker33_pos = _attacker3.get_pos(); |
dongyuhu | 0:9e95a5ef2659 | 91 | Vector2D attacker44_pos = _attacker4.get_pos(); |
dongyuhu | 0:9e95a5ef2659 | 92 | Vector2D attacker55_pos = _attacker5.get_pos(); |
dongyuhu | 0:9e95a5ef2659 | 93 | Vector2D attacker66_pos = _attacker6.get_pos(); |
dongyuhu | 0:9e95a5ef2659 | 94 | Vector2D attacker77_pos = _attacker7.get_pos(); |
dongyuhu | 0:9e95a5ef2659 | 95 | Vector2D attacker88_pos = _attacker8.get_pos(); |
dongyuhu | 0:9e95a5ef2659 | 96 | |
dongyuhu | 0:9e95a5ef2659 | 97 | |
dongyuhu | 0:9e95a5ef2659 | 98 | if(attacker11_pos.y < 10) //if collision, |
dongyuhu | 0:9e95a5ef2659 | 99 | { |
dongyuhu | 0:9e95a5ef2659 | 100 | attacker11_pos.x=30; // position restore. |
dongyuhu | 0:9e95a5ef2659 | 101 | attacker11_pos.y=11; //every attacker ,totally 8 times. |
dongyuhu | 0:9e95a5ef2659 | 102 | } |
dongyuhu | 0:9e95a5ef2659 | 103 | else if(attacker11_pos.y > 36) |
dongyuhu | 0:9e95a5ef2659 | 104 | { |
dongyuhu | 0:9e95a5ef2659 | 105 | attacker11_pos.x=30; |
dongyuhu | 0:9e95a5ef2659 | 106 | attacker11_pos.y=11; |
dongyuhu | 0:9e95a5ef2659 | 107 | } |
dongyuhu | 0:9e95a5ef2659 | 108 | else if(attacker11_pos.x < 10) |
dongyuhu | 0:9e95a5ef2659 | 109 | { |
dongyuhu | 0:9e95a5ef2659 | 110 | attacker11_pos.x=30; |
dongyuhu | 0:9e95a5ef2659 | 111 | attacker11_pos.y=11; |
dongyuhu | 0:9e95a5ef2659 | 112 | } |
dongyuhu | 0:9e95a5ef2659 | 113 | else if(attacker11_pos.x > 72) |
dongyuhu | 0:9e95a5ef2659 | 114 | { |
dongyuhu | 0:9e95a5ef2659 | 115 | attacker11_pos.x=30; |
dongyuhu | 0:9e95a5ef2659 | 116 | attacker11_pos.y=11; |
dongyuhu | 0:9e95a5ef2659 | 117 | } |
dongyuhu | 0:9e95a5ef2659 | 118 | |
dongyuhu | 0:9e95a5ef2659 | 119 | if(attacker22_pos.y < 10) |
dongyuhu | 0:9e95a5ef2659 | 120 | { |
dongyuhu | 0:9e95a5ef2659 | 121 | attacker22_pos.x=54; |
dongyuhu | 0:9e95a5ef2659 | 122 | attacker22_pos.y=10; |
dongyuhu | 0:9e95a5ef2659 | 123 | } |
dongyuhu | 0:9e95a5ef2659 | 124 | else if(attacker22_pos.y > 36) |
dongyuhu | 0:9e95a5ef2659 | 125 | { |
dongyuhu | 0:9e95a5ef2659 | 126 | attacker22_pos.x=54; |
dongyuhu | 0:9e95a5ef2659 | 127 | attacker22_pos.y=10; |
dongyuhu | 0:9e95a5ef2659 | 128 | } |
dongyuhu | 0:9e95a5ef2659 | 129 | else if(attacker22_pos.x < 10) |
dongyuhu | 0:9e95a5ef2659 | 130 | { |
dongyuhu | 0:9e95a5ef2659 | 131 | attacker22_pos.x=54; |
dongyuhu | 0:9e95a5ef2659 | 132 | attacker22_pos.y=10; |
dongyuhu | 0:9e95a5ef2659 | 133 | } |
dongyuhu | 0:9e95a5ef2659 | 134 | else if(attacker22_pos.x > 72) |
dongyuhu | 0:9e95a5ef2659 | 135 | { |
dongyuhu | 0:9e95a5ef2659 | 136 | attacker22_pos.x=54; |
dongyuhu | 0:9e95a5ef2659 | 137 | attacker22_pos.y=10; |
dongyuhu | 0:9e95a5ef2659 | 138 | } |
dongyuhu | 0:9e95a5ef2659 | 139 | |
dongyuhu | 0:9e95a5ef2659 | 140 | if(attacker33_pos.y < 10) |
dongyuhu | 0:9e95a5ef2659 | 141 | { |
dongyuhu | 0:9e95a5ef2659 | 142 | attacker33_pos.x=10; |
dongyuhu | 0:9e95a5ef2659 | 143 | attacker33_pos.y=17; |
dongyuhu | 0:9e95a5ef2659 | 144 | } |
dongyuhu | 0:9e95a5ef2659 | 145 | else if(attacker33_pos.y > 36) |
dongyuhu | 0:9e95a5ef2659 | 146 | { |
dongyuhu | 0:9e95a5ef2659 | 147 | attacker33_pos.x=10; |
dongyuhu | 0:9e95a5ef2659 | 148 | attacker33_pos.y=17; |
dongyuhu | 0:9e95a5ef2659 | 149 | } |
dongyuhu | 0:9e95a5ef2659 | 150 | else if(attacker33_pos.x < 10) |
dongyuhu | 0:9e95a5ef2659 | 151 | { |
dongyuhu | 0:9e95a5ef2659 | 152 | attacker33_pos.x=10; |
dongyuhu | 0:9e95a5ef2659 | 153 | attacker33_pos.y=17; |
dongyuhu | 0:9e95a5ef2659 | 154 | } |
dongyuhu | 0:9e95a5ef2659 | 155 | else if(attacker33_pos.x > 72) |
dongyuhu | 0:9e95a5ef2659 | 156 | { |
dongyuhu | 0:9e95a5ef2659 | 157 | attacker33_pos.x=10; |
dongyuhu | 0:9e95a5ef2659 | 158 | attacker33_pos.y=17; |
dongyuhu | 0:9e95a5ef2659 | 159 | } |
dongyuhu | 0:9e95a5ef2659 | 160 | |
dongyuhu | 0:9e95a5ef2659 | 161 | if(attacker44_pos.y < 10) |
dongyuhu | 0:9e95a5ef2659 | 162 | { |
dongyuhu | 0:9e95a5ef2659 | 163 | attacker44_pos.x=10; |
dongyuhu | 0:9e95a5ef2659 | 164 | attacker44_pos.y=31; |
dongyuhu | 0:9e95a5ef2659 | 165 | } |
dongyuhu | 0:9e95a5ef2659 | 166 | else if(attacker44_pos.y > 36) |
dongyuhu | 0:9e95a5ef2659 | 167 | { |
dongyuhu | 0:9e95a5ef2659 | 168 | attacker44_pos.x=10; |
dongyuhu | 0:9e95a5ef2659 | 169 | attacker44_pos.y=31; |
dongyuhu | 0:9e95a5ef2659 | 170 | } |
dongyuhu | 0:9e95a5ef2659 | 171 | else if(attacker11_pos.x < 10) |
dongyuhu | 0:9e95a5ef2659 | 172 | { |
dongyuhu | 0:9e95a5ef2659 | 173 | attacker44_pos.x=10; |
dongyuhu | 0:9e95a5ef2659 | 174 | attacker44_pos.y=31; |
dongyuhu | 0:9e95a5ef2659 | 175 | } |
dongyuhu | 0:9e95a5ef2659 | 176 | else if(attacker44_pos.x > 72) |
dongyuhu | 0:9e95a5ef2659 | 177 | { |
dongyuhu | 0:9e95a5ef2659 | 178 | attacker44_pos.x=10; |
dongyuhu | 0:9e95a5ef2659 | 179 | attacker44_pos.y=31; |
dongyuhu | 0:9e95a5ef2659 | 180 | } |
dongyuhu | 0:9e95a5ef2659 | 181 | |
dongyuhu | 0:9e95a5ef2659 | 182 | if(attacker55_pos.y < 10) |
dongyuhu | 0:9e95a5ef2659 | 183 | { |
dongyuhu | 0:9e95a5ef2659 | 184 | attacker55_pos.x=30; |
dongyuhu | 0:9e95a5ef2659 | 185 | attacker55_pos.y=36; |
dongyuhu | 0:9e95a5ef2659 | 186 | } |
dongyuhu | 0:9e95a5ef2659 | 187 | else if(attacker55_pos.y > 36) |
dongyuhu | 0:9e95a5ef2659 | 188 | { |
dongyuhu | 0:9e95a5ef2659 | 189 | attacker55_pos.x=30; |
dongyuhu | 0:9e95a5ef2659 | 190 | attacker55_pos.y=36; |
dongyuhu | 0:9e95a5ef2659 | 191 | } |
dongyuhu | 0:9e95a5ef2659 | 192 | else if(attacker55_pos.x < 10) |
dongyuhu | 0:9e95a5ef2659 | 193 | { |
dongyuhu | 0:9e95a5ef2659 | 194 | attacker55_pos.x=30; |
dongyuhu | 0:9e95a5ef2659 | 195 | attacker55_pos.y=36; |
dongyuhu | 0:9e95a5ef2659 | 196 | } |
dongyuhu | 0:9e95a5ef2659 | 197 | else if(attacker55_pos.x > 72) |
dongyuhu | 0:9e95a5ef2659 | 198 | { |
dongyuhu | 0:9e95a5ef2659 | 199 | attacker55_pos.x=30; |
dongyuhu | 0:9e95a5ef2659 | 200 | attacker55_pos.y=36; |
dongyuhu | 0:9e95a5ef2659 | 201 | } |
dongyuhu | 0:9e95a5ef2659 | 202 | |
dongyuhu | 0:9e95a5ef2659 | 203 | if(attacker66_pos.y < 10) |
dongyuhu | 0:9e95a5ef2659 | 204 | { |
dongyuhu | 0:9e95a5ef2659 | 205 | attacker66_pos.x=54; |
dongyuhu | 0:9e95a5ef2659 | 206 | attacker66_pos.y=36; |
dongyuhu | 0:9e95a5ef2659 | 207 | } |
dongyuhu | 0:9e95a5ef2659 | 208 | else if(attacker66_pos.y > 36) |
dongyuhu | 0:9e95a5ef2659 | 209 | { |
dongyuhu | 0:9e95a5ef2659 | 210 | attacker66_pos.x=54; |
dongyuhu | 0:9e95a5ef2659 | 211 | attacker66_pos.y=36; |
dongyuhu | 0:9e95a5ef2659 | 212 | } |
dongyuhu | 0:9e95a5ef2659 | 213 | else if(attacker66_pos.x < 10) |
dongyuhu | 0:9e95a5ef2659 | 214 | { |
dongyuhu | 0:9e95a5ef2659 | 215 | attacker66_pos.x=54; |
dongyuhu | 0:9e95a5ef2659 | 216 | attacker66_pos.y=36; |
dongyuhu | 0:9e95a5ef2659 | 217 | } |
dongyuhu | 0:9e95a5ef2659 | 218 | else if(attacker66_pos.x > 72) |
dongyuhu | 0:9e95a5ef2659 | 219 | { |
dongyuhu | 0:9e95a5ef2659 | 220 | attacker66_pos.x=54; |
dongyuhu | 0:9e95a5ef2659 | 221 | attacker66_pos.y=36; |
dongyuhu | 0:9e95a5ef2659 | 222 | } |
dongyuhu | 0:9e95a5ef2659 | 223 | |
dongyuhu | 0:9e95a5ef2659 | 224 | if(attacker77_pos.y < 10) |
dongyuhu | 0:9e95a5ef2659 | 225 | { |
dongyuhu | 0:9e95a5ef2659 | 226 | attacker77_pos.x=71; |
dongyuhu | 0:9e95a5ef2659 | 227 | attacker77_pos.y=31; |
dongyuhu | 0:9e95a5ef2659 | 228 | } |
dongyuhu | 0:9e95a5ef2659 | 229 | else if(attacker77_pos.y > 36) |
dongyuhu | 0:9e95a5ef2659 | 230 | { |
dongyuhu | 0:9e95a5ef2659 | 231 | attacker77_pos.x=71; |
dongyuhu | 0:9e95a5ef2659 | 232 | attacker77_pos.y=31; |
dongyuhu | 0:9e95a5ef2659 | 233 | } |
dongyuhu | 0:9e95a5ef2659 | 234 | else if(attacker77_pos.x < 10) |
dongyuhu | 0:9e95a5ef2659 | 235 | { |
dongyuhu | 0:9e95a5ef2659 | 236 | attacker77_pos.x=71; |
dongyuhu | 0:9e95a5ef2659 | 237 | attacker77_pos.y=31; |
dongyuhu | 0:9e95a5ef2659 | 238 | } |
dongyuhu | 0:9e95a5ef2659 | 239 | else if(attacker77_pos.x > 72) |
dongyuhu | 0:9e95a5ef2659 | 240 | { |
dongyuhu | 0:9e95a5ef2659 | 241 | attacker77_pos.x=71; |
dongyuhu | 0:9e95a5ef2659 | 242 | attacker77_pos.y=31; |
dongyuhu | 0:9e95a5ef2659 | 243 | } |
dongyuhu | 0:9e95a5ef2659 | 244 | |
dongyuhu | 0:9e95a5ef2659 | 245 | if(attacker88_pos.y < 10) |
dongyuhu | 0:9e95a5ef2659 | 246 | { |
dongyuhu | 0:9e95a5ef2659 | 247 | attacker88_pos.x=71; |
dongyuhu | 0:9e95a5ef2659 | 248 | attacker88_pos.y=17; |
dongyuhu | 0:9e95a5ef2659 | 249 | } |
dongyuhu | 0:9e95a5ef2659 | 250 | else if(attacker88_pos.y > 36) |
dongyuhu | 0:9e95a5ef2659 | 251 | { |
dongyuhu | 0:9e95a5ef2659 | 252 | attacker88_pos.x=71; |
dongyuhu | 0:9e95a5ef2659 | 253 | attacker88_pos.y=17; |
dongyuhu | 0:9e95a5ef2659 | 254 | } |
dongyuhu | 0:9e95a5ef2659 | 255 | else if(attacker88_pos.x < 10) |
dongyuhu | 0:9e95a5ef2659 | 256 | { |
dongyuhu | 0:9e95a5ef2659 | 257 | attacker88_pos.x=71; |
dongyuhu | 0:9e95a5ef2659 | 258 | attacker88_pos.y=17; |
dongyuhu | 0:9e95a5ef2659 | 259 | } |
dongyuhu | 0:9e95a5ef2659 | 260 | else if(attacker88_pos.x > 72) |
dongyuhu | 0:9e95a5ef2659 | 261 | { |
dongyuhu | 0:9e95a5ef2659 | 262 | attacker88_pos.x=71; |
dongyuhu | 0:9e95a5ef2659 | 263 | attacker88_pos.y=17; |
dongyuhu | 0:9e95a5ef2659 | 264 | } |
dongyuhu | 0:9e95a5ef2659 | 265 | |
dongyuhu | 0:9e95a5ef2659 | 266 | _attacker1.set_pos(attacker11_pos); |
dongyuhu | 0:9e95a5ef2659 | 267 | _attacker2.set_pos(attacker22_pos); |
dongyuhu | 0:9e95a5ef2659 | 268 | _attacker3.set_pos(attacker33_pos); |
dongyuhu | 0:9e95a5ef2659 | 269 | _attacker4.set_pos(attacker44_pos); |
dongyuhu | 0:9e95a5ef2659 | 270 | _attacker5.set_pos(attacker55_pos); |
dongyuhu | 0:9e95a5ef2659 | 271 | _attacker6.set_pos(attacker66_pos); |
dongyuhu | 0:9e95a5ef2659 | 272 | _attacker7.set_pos(attacker77_pos); |
dongyuhu | 0:9e95a5ef2659 | 273 | _attacker8.set_pos(attacker88_pos); |
dongyuhu | 0:9e95a5ef2659 | 274 | |
dongyuhu | 0:9e95a5ef2659 | 275 | } |
dongyuhu | 0:9e95a5ef2659 | 276 | |
dongyuhu | 0:9e95a5ef2659 | 277 | |
dongyuhu | 0:9e95a5ef2659 | 278 | void Start::check_body_collisions(Gamepad &pad) |
dongyuhu | 0:9e95a5ef2659 | 279 | { |
dongyuhu | 0:9e95a5ef2659 | 280 | Vector2D attacker11_pos = _attacker1.get_pos(); |
dongyuhu | 0:9e95a5ef2659 | 281 | Vector2D attacker22_pos = _attacker2.get_pos(); |
dongyuhu | 0:9e95a5ef2659 | 282 | Vector2D attacker33_pos = _attacker3.get_pos(); |
dongyuhu | 0:9e95a5ef2659 | 283 | Vector2D attacker44_pos = _attacker4.get_pos(); |
dongyuhu | 0:9e95a5ef2659 | 284 | Vector2D attacker55_pos = _attacker5.get_pos(); |
dongyuhu | 0:9e95a5ef2659 | 285 | Vector2D attacker66_pos = _attacker6.get_pos(); |
dongyuhu | 0:9e95a5ef2659 | 286 | Vector2D attacker77_pos = _attacker7.get_pos(); |
dongyuhu | 0:9e95a5ef2659 | 287 | Vector2D attacker88_pos = _attacker8.get_pos(); |
dongyuhu | 0:9e95a5ef2659 | 288 | |
dongyuhu | 0:9e95a5ef2659 | 289 | |
dongyuhu | 0:9e95a5ef2659 | 290 | Vector2D me_pos = _me.get_pos(); |
dongyuhu | 0:9e95a5ef2659 | 291 | if ((attacker11_pos.x+1 == me_pos.x) &&(attacker11_pos.y+1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 292 | (attacker11_pos.x+1 == me_pos.x) &&(attacker11_pos.y == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 293 | (attacker11_pos.x+1 == me_pos.x) &&(attacker11_pos.y-1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 294 | (attacker11_pos.x+1 == me_pos.x) &&(attacker11_pos.y-2 == me_pos.y) //if attacker collides me from left |
dongyuhu | 0:9e95a5ef2659 | 295 | ) |
dongyuhu | 0:9e95a5ef2659 | 296 | { |
dongyuhu | 0:9e95a5ef2659 | 297 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 298 | attacker11_pos.x=30; //attacker back to initial position |
dongyuhu | 0:9e95a5ef2659 | 299 | attacker11_pos.y=11; |
dongyuhu | 0:9e95a5ef2659 | 300 | } |
dongyuhu | 0:9e95a5ef2659 | 301 | if ((attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y+1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 302 | (attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 303 | (attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y-1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 304 | (attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y-2 == me_pos.y) //right |
dongyuhu | 0:9e95a5ef2659 | 305 | ) |
dongyuhu | 0:9e95a5ef2659 | 306 | { |
dongyuhu | 0:9e95a5ef2659 | 307 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 308 | attacker11_pos.x=30; |
dongyuhu | 0:9e95a5ef2659 | 309 | attacker11_pos.y=11; |
dongyuhu | 0:9e95a5ef2659 | 310 | } |
dongyuhu | 0:9e95a5ef2659 | 311 | if ((attacker11_pos.x == me_pos.x-1) &&(attacker11_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 312 | (attacker11_pos.x == me_pos.x ) &&(attacker11_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 313 | (attacker11_pos.x == me_pos.x+1) &&(attacker11_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 314 | (attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y+2 == me_pos.y+1) //up |
dongyuhu | 0:9e95a5ef2659 | 315 | ) |
dongyuhu | 0:9e95a5ef2659 | 316 | { |
dongyuhu | 0:9e95a5ef2659 | 317 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 318 | attacker11_pos.x=30; |
dongyuhu | 0:9e95a5ef2659 | 319 | attacker11_pos.y=11; |
dongyuhu | 0:9e95a5ef2659 | 320 | } |
dongyuhu | 0:9e95a5ef2659 | 321 | if ((attacker11_pos.x == me_pos.x-1) &&(attacker11_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 322 | (attacker11_pos.x == me_pos.x ) &&(attacker11_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 323 | (attacker11_pos.x == me_pos.x+1) &&(attacker11_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 324 | (attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y == me_pos.y+2) //down |
dongyuhu | 0:9e95a5ef2659 | 325 | ) |
dongyuhu | 0:9e95a5ef2659 | 326 | { |
dongyuhu | 0:9e95a5ef2659 | 327 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 328 | attacker11_pos.x=30; |
dongyuhu | 0:9e95a5ef2659 | 329 | attacker11_pos.y=11; |
dongyuhu | 0:9e95a5ef2659 | 330 | } |
dongyuhu | 0:9e95a5ef2659 | 331 | ///////////////////////////////////////////////////////////////////////////////////////////////// |
dongyuhu | 0:9e95a5ef2659 | 332 | |
dongyuhu | 0:9e95a5ef2659 | 333 | if ((attacker22_pos.x+1 == me_pos.x) &&(attacker22_pos.y+1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 334 | (attacker22_pos.x+1 == me_pos.x) &&(attacker22_pos.y == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 335 | (attacker22_pos.x+1 == me_pos.x) &&(attacker22_pos.y-1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 336 | (attacker22_pos.x+1 == me_pos.x) &&(attacker22_pos.y-2 == me_pos.y) //left |
dongyuhu | 0:9e95a5ef2659 | 337 | ) |
dongyuhu | 0:9e95a5ef2659 | 338 | { |
dongyuhu | 0:9e95a5ef2659 | 339 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 340 | attacker22_pos.x=54; |
dongyuhu | 0:9e95a5ef2659 | 341 | attacker22_pos.y=10; |
dongyuhu | 0:9e95a5ef2659 | 342 | } |
dongyuhu | 0:9e95a5ef2659 | 343 | if ((attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y+1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 344 | (attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 345 | (attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y-1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 346 | (attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y-2 == me_pos.y) //right |
dongyuhu | 0:9e95a5ef2659 | 347 | ) |
dongyuhu | 0:9e95a5ef2659 | 348 | { |
dongyuhu | 0:9e95a5ef2659 | 349 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 350 | attacker22_pos.x=54; |
dongyuhu | 0:9e95a5ef2659 | 351 | attacker22_pos.y=10; |
dongyuhu | 0:9e95a5ef2659 | 352 | } |
dongyuhu | 0:9e95a5ef2659 | 353 | if ((attacker22_pos.x == me_pos.x-1) &&(attacker22_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 354 | (attacker22_pos.x == me_pos.x ) &&(attacker22_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 355 | (attacker22_pos.x == me_pos.x+1) &&(attacker22_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 356 | (attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y+2 == me_pos.y+1) //up |
dongyuhu | 0:9e95a5ef2659 | 357 | ) |
dongyuhu | 0:9e95a5ef2659 | 358 | { |
dongyuhu | 0:9e95a5ef2659 | 359 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 360 | attacker22_pos.x=54; |
dongyuhu | 0:9e95a5ef2659 | 361 | attacker22_pos.y=10; |
dongyuhu | 0:9e95a5ef2659 | 362 | } |
dongyuhu | 0:9e95a5ef2659 | 363 | if ((attacker22_pos.x == me_pos.x-1) &&(attacker22_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 364 | (attacker22_pos.x == me_pos.x ) &&(attacker22_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 365 | (attacker22_pos.x == me_pos.x+1) &&(attacker22_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 366 | (attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y == me_pos.y+2) //down |
dongyuhu | 0:9e95a5ef2659 | 367 | ) |
dongyuhu | 0:9e95a5ef2659 | 368 | { |
dongyuhu | 0:9e95a5ef2659 | 369 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 370 | attacker22_pos.x=54; |
dongyuhu | 0:9e95a5ef2659 | 371 | attacker22_pos.y=10; |
dongyuhu | 0:9e95a5ef2659 | 372 | } |
dongyuhu | 0:9e95a5ef2659 | 373 | ///////////////////////////////////////////////////////////////// |
dongyuhu | 0:9e95a5ef2659 | 374 | if ((attacker33_pos.x+1 == me_pos.x) &&(attacker33_pos.y+1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 375 | (attacker33_pos.x+1 == me_pos.x) &&(attacker33_pos.y == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 376 | (attacker33_pos.x+1 == me_pos.x) &&(attacker33_pos.y-1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 377 | (attacker33_pos.x+1 == me_pos.x) &&(attacker33_pos.y-2 == me_pos.y) //left |
dongyuhu | 0:9e95a5ef2659 | 378 | ) |
dongyuhu | 0:9e95a5ef2659 | 379 | { |
dongyuhu | 0:9e95a5ef2659 | 380 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 381 | attacker33_pos.x=10; |
dongyuhu | 0:9e95a5ef2659 | 382 | attacker33_pos.y=17; |
dongyuhu | 0:9e95a5ef2659 | 383 | } |
dongyuhu | 0:9e95a5ef2659 | 384 | if ((attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y+1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 385 | (attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 386 | (attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y-1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 387 | (attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y-2 == me_pos.y) //right |
dongyuhu | 0:9e95a5ef2659 | 388 | ) |
dongyuhu | 0:9e95a5ef2659 | 389 | { |
dongyuhu | 0:9e95a5ef2659 | 390 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 391 | attacker33_pos.x=10; |
dongyuhu | 0:9e95a5ef2659 | 392 | attacker33_pos.y=17; |
dongyuhu | 0:9e95a5ef2659 | 393 | } |
dongyuhu | 0:9e95a5ef2659 | 394 | if ((attacker33_pos.x == me_pos.x-1) &&(attacker33_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 395 | (attacker33_pos.x == me_pos.x ) &&(attacker33_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 396 | (attacker33_pos.x == me_pos.x+1) &&(attacker33_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 397 | (attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y+2 == me_pos.y+1) //up |
dongyuhu | 0:9e95a5ef2659 | 398 | ) |
dongyuhu | 0:9e95a5ef2659 | 399 | { |
dongyuhu | 0:9e95a5ef2659 | 400 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 401 | attacker33_pos.x=10; |
dongyuhu | 0:9e95a5ef2659 | 402 | attacker33_pos.y=17; |
dongyuhu | 0:9e95a5ef2659 | 403 | } |
dongyuhu | 0:9e95a5ef2659 | 404 | if ((attacker33_pos.x == me_pos.x-1) &&(attacker33_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 405 | (attacker33_pos.x == me_pos.x ) &&(attacker33_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 406 | (attacker33_pos.x == me_pos.x+1) &&(attacker33_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 407 | (attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y == me_pos.y+2) //down |
dongyuhu | 0:9e95a5ef2659 | 408 | ) |
dongyuhu | 0:9e95a5ef2659 | 409 | { |
dongyuhu | 0:9e95a5ef2659 | 410 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 411 | attacker33_pos.x=10; |
dongyuhu | 0:9e95a5ef2659 | 412 | attacker33_pos.y=17; |
dongyuhu | 0:9e95a5ef2659 | 413 | } |
dongyuhu | 0:9e95a5ef2659 | 414 | ///////////////////////////////////////////////////////////////////////////////////////////////// |
dongyuhu | 0:9e95a5ef2659 | 415 | |
dongyuhu | 0:9e95a5ef2659 | 416 | if ((attacker44_pos.x+1 == me_pos.x) &&(attacker44_pos.y+1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 417 | (attacker44_pos.x+1 == me_pos.x) &&(attacker44_pos.y == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 418 | (attacker44_pos.x+1 == me_pos.x) &&(attacker44_pos.y-1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 419 | (attacker44_pos.x+1 == me_pos.x) &&(attacker44_pos.y-2 == me_pos.y) //left |
dongyuhu | 0:9e95a5ef2659 | 420 | ) |
dongyuhu | 0:9e95a5ef2659 | 421 | { |
dongyuhu | 0:9e95a5ef2659 | 422 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 423 | attacker44_pos.x=10; |
dongyuhu | 0:9e95a5ef2659 | 424 | attacker44_pos.y=31; |
dongyuhu | 0:9e95a5ef2659 | 425 | } |
dongyuhu | 0:9e95a5ef2659 | 426 | if ((attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y+1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 427 | (attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 428 | (attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y-1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 429 | (attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y-2 == me_pos.y) //right |
dongyuhu | 0:9e95a5ef2659 | 430 | ) |
dongyuhu | 0:9e95a5ef2659 | 431 | { |
dongyuhu | 0:9e95a5ef2659 | 432 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 433 | attacker44_pos.x=10; |
dongyuhu | 0:9e95a5ef2659 | 434 | attacker44_pos.y=31; |
dongyuhu | 0:9e95a5ef2659 | 435 | } |
dongyuhu | 0:9e95a5ef2659 | 436 | if ((attacker44_pos.x == me_pos.x-1) &&(attacker44_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 437 | (attacker44_pos.x == me_pos.x ) &&(attacker44_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 438 | (attacker44_pos.x == me_pos.x+1) &&(attacker44_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 439 | (attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y+2 == me_pos.y+1) //up |
dongyuhu | 0:9e95a5ef2659 | 440 | ) |
dongyuhu | 0:9e95a5ef2659 | 441 | { |
dongyuhu | 0:9e95a5ef2659 | 442 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 443 | attacker44_pos.x=10; |
dongyuhu | 0:9e95a5ef2659 | 444 | attacker44_pos.y=31; |
dongyuhu | 0:9e95a5ef2659 | 445 | } |
dongyuhu | 0:9e95a5ef2659 | 446 | if ((attacker44_pos.x == me_pos.x-1) &&(attacker44_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 447 | (attacker44_pos.x == me_pos.x ) &&(attacker44_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 448 | (attacker44_pos.x == me_pos.x+1) &&(attacker44_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 449 | (attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y == me_pos.y+2) //down |
dongyuhu | 0:9e95a5ef2659 | 450 | ) |
dongyuhu | 0:9e95a5ef2659 | 451 | { |
dongyuhu | 0:9e95a5ef2659 | 452 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 453 | attacker44_pos.x=10; |
dongyuhu | 0:9e95a5ef2659 | 454 | attacker44_pos.y=31; |
dongyuhu | 0:9e95a5ef2659 | 455 | } |
dongyuhu | 0:9e95a5ef2659 | 456 | /////////////////////////////////////////////////////////////////// |
dongyuhu | 0:9e95a5ef2659 | 457 | if ((attacker55_pos.x+1 == me_pos.x) &&(attacker55_pos.y+1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 458 | (attacker55_pos.x+1 == me_pos.x) &&(attacker55_pos.y == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 459 | (attacker55_pos.x+1 == me_pos.x) &&(attacker55_pos.y-1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 460 | (attacker55_pos.x+1 == me_pos.x) &&(attacker55_pos.y-2 == me_pos.y) //left |
dongyuhu | 0:9e95a5ef2659 | 461 | ) |
dongyuhu | 0:9e95a5ef2659 | 462 | { |
dongyuhu | 0:9e95a5ef2659 | 463 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 464 | attacker55_pos.x=30; |
dongyuhu | 0:9e95a5ef2659 | 465 | attacker55_pos.y=38; |
dongyuhu | 0:9e95a5ef2659 | 466 | } |
dongyuhu | 0:9e95a5ef2659 | 467 | if ((attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y+1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 468 | (attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 469 | (attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y-1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 470 | (attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y-2 == me_pos.y) //right |
dongyuhu | 0:9e95a5ef2659 | 471 | ) |
dongyuhu | 0:9e95a5ef2659 | 472 | { |
dongyuhu | 0:9e95a5ef2659 | 473 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 474 | attacker11_pos.x=30; |
dongyuhu | 0:9e95a5ef2659 | 475 | attacker11_pos.y=38; |
dongyuhu | 0:9e95a5ef2659 | 476 | } |
dongyuhu | 0:9e95a5ef2659 | 477 | if ((attacker55_pos.x == me_pos.x-1) &&(attacker55_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 478 | (attacker55_pos.x == me_pos.x ) &&(attacker55_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 479 | (attacker55_pos.x == me_pos.x+1) &&(attacker55_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 480 | (attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y+2 == me_pos.y+1) //up |
dongyuhu | 0:9e95a5ef2659 | 481 | ) |
dongyuhu | 0:9e95a5ef2659 | 482 | { |
dongyuhu | 0:9e95a5ef2659 | 483 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 484 | attacker55_pos.x=30; |
dongyuhu | 0:9e95a5ef2659 | 485 | attacker55_pos.y=38; |
dongyuhu | 0:9e95a5ef2659 | 486 | } |
dongyuhu | 0:9e95a5ef2659 | 487 | if ((attacker55_pos.x == me_pos.x-1) &&(attacker55_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 488 | (attacker55_pos.x == me_pos.x ) &&(attacker55_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 489 | (attacker55_pos.x == me_pos.x+1) &&(attacker55_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 490 | (attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y == me_pos.y+2) //down |
dongyuhu | 0:9e95a5ef2659 | 491 | ) |
dongyuhu | 0:9e95a5ef2659 | 492 | { |
dongyuhu | 0:9e95a5ef2659 | 493 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 494 | attacker55_pos.x=30; |
dongyuhu | 0:9e95a5ef2659 | 495 | attacker55_pos.y=38; |
dongyuhu | 0:9e95a5ef2659 | 496 | } |
dongyuhu | 0:9e95a5ef2659 | 497 | ///////////////////////////////////////////////////////////////////////////////////////////////// |
dongyuhu | 0:9e95a5ef2659 | 498 | |
dongyuhu | 0:9e95a5ef2659 | 499 | if ((attacker66_pos.x+1 == me_pos.x) &&(attacker66_pos.y+1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 500 | (attacker66_pos.x+1 == me_pos.x) &&(attacker66_pos.y == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 501 | (attacker66_pos.x+1 == me_pos.x) &&(attacker66_pos.y-1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 502 | (attacker66_pos.x+1 == me_pos.x) &&(attacker66_pos.y-2 == me_pos.y) //left |
dongyuhu | 0:9e95a5ef2659 | 503 | ) |
dongyuhu | 0:9e95a5ef2659 | 504 | { |
dongyuhu | 0:9e95a5ef2659 | 505 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 506 | attacker66_pos.x=54; |
dongyuhu | 0:9e95a5ef2659 | 507 | attacker66_pos.y=38; |
dongyuhu | 0:9e95a5ef2659 | 508 | } |
dongyuhu | 0:9e95a5ef2659 | 509 | if ((attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y+1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 510 | (attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 511 | (attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y-1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 512 | (attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y-2 == me_pos.y) //right |
dongyuhu | 0:9e95a5ef2659 | 513 | ) |
dongyuhu | 0:9e95a5ef2659 | 514 | { |
dongyuhu | 0:9e95a5ef2659 | 515 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 516 | attacker66_pos.x=54; |
dongyuhu | 0:9e95a5ef2659 | 517 | attacker66_pos.y=38; |
dongyuhu | 0:9e95a5ef2659 | 518 | } |
dongyuhu | 0:9e95a5ef2659 | 519 | if ((attacker66_pos.x == me_pos.x-1) &&(attacker66_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 520 | (attacker66_pos.x == me_pos.x ) &&(attacker66_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 521 | (attacker66_pos.x == me_pos.x+1) &&(attacker66_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 522 | (attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y+2 == me_pos.y+1) //up |
dongyuhu | 0:9e95a5ef2659 | 523 | ) |
dongyuhu | 0:9e95a5ef2659 | 524 | { |
dongyuhu | 0:9e95a5ef2659 | 525 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 526 | attacker66_pos.x=54; |
dongyuhu | 0:9e95a5ef2659 | 527 | attacker66_pos.y=38; |
dongyuhu | 0:9e95a5ef2659 | 528 | } |
dongyuhu | 0:9e95a5ef2659 | 529 | if ((attacker66_pos.x == me_pos.x-1) &&(attacker66_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 530 | (attacker66_pos.x == me_pos.x ) &&(attacker66_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 531 | (attacker66_pos.x == me_pos.x+1) &&(attacker66_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 532 | (attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y == me_pos.y+2) //down |
dongyuhu | 0:9e95a5ef2659 | 533 | ) |
dongyuhu | 0:9e95a5ef2659 | 534 | { |
dongyuhu | 0:9e95a5ef2659 | 535 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 536 | attacker66_pos.x=54; |
dongyuhu | 0:9e95a5ef2659 | 537 | attacker66_pos.y=38; |
dongyuhu | 0:9e95a5ef2659 | 538 | } |
dongyuhu | 0:9e95a5ef2659 | 539 | /////////////////////////////////////////////////////// |
dongyuhu | 0:9e95a5ef2659 | 540 | if ((attacker77_pos.x+1 == me_pos.x) &&(attacker77_pos.y+1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 541 | (attacker77_pos.x+1 == me_pos.x) &&(attacker77_pos.y == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 542 | (attacker77_pos.x+1 == me_pos.x) &&(attacker77_pos.y-1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 543 | (attacker77_pos.x+1 == me_pos.x) &&(attacker77_pos.y-2 == me_pos.y) //left |
dongyuhu | 0:9e95a5ef2659 | 544 | ) |
dongyuhu | 0:9e95a5ef2659 | 545 | { |
dongyuhu | 0:9e95a5ef2659 | 546 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 547 | attacker77_pos.x=74; |
dongyuhu | 0:9e95a5ef2659 | 548 | attacker77_pos.y=31; |
dongyuhu | 0:9e95a5ef2659 | 549 | } |
dongyuhu | 0:9e95a5ef2659 | 550 | if ((attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y+1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 551 | (attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 552 | (attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y-1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 553 | (attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y-2 == me_pos.y) //right |
dongyuhu | 0:9e95a5ef2659 | 554 | ) |
dongyuhu | 0:9e95a5ef2659 | 555 | { |
dongyuhu | 0:9e95a5ef2659 | 556 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 557 | attacker77_pos.x=74; |
dongyuhu | 0:9e95a5ef2659 | 558 | attacker77_pos.y=31; |
dongyuhu | 0:9e95a5ef2659 | 559 | } |
dongyuhu | 0:9e95a5ef2659 | 560 | if ((attacker77_pos.x == me_pos.x-1) &&(attacker77_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 561 | (attacker77_pos.x == me_pos.x ) &&(attacker77_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 562 | (attacker77_pos.x == me_pos.x+1) &&(attacker77_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 563 | (attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y+2 == me_pos.y+1) //up |
dongyuhu | 0:9e95a5ef2659 | 564 | ) |
dongyuhu | 0:9e95a5ef2659 | 565 | { |
dongyuhu | 0:9e95a5ef2659 | 566 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 567 | attacker77_pos.x=74; |
dongyuhu | 0:9e95a5ef2659 | 568 | attacker77_pos.y=31; |
dongyuhu | 0:9e95a5ef2659 | 569 | } |
dongyuhu | 0:9e95a5ef2659 | 570 | if ((attacker77_pos.x == me_pos.x-1) &&(attacker77_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 571 | (attacker77_pos.x == me_pos.x ) &&(attacker77_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 572 | (attacker77_pos.x == me_pos.x+1) &&(attacker77_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 573 | (attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y == me_pos.y+2) //down |
dongyuhu | 0:9e95a5ef2659 | 574 | ) |
dongyuhu | 0:9e95a5ef2659 | 575 | { |
dongyuhu | 0:9e95a5ef2659 | 576 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 577 | attacker77_pos.x=74; |
dongyuhu | 0:9e95a5ef2659 | 578 | attacker77_pos.y=31; |
dongyuhu | 0:9e95a5ef2659 | 579 | } |
dongyuhu | 0:9e95a5ef2659 | 580 | ///////////////////////////////////////////////////////////////////////////////////////////////// |
dongyuhu | 0:9e95a5ef2659 | 581 | |
dongyuhu | 0:9e95a5ef2659 | 582 | if ((attacker88_pos.x+1 == me_pos.x) &&(attacker88_pos.y+1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 583 | (attacker88_pos.x+1 == me_pos.x) &&(attacker88_pos.y == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 584 | (attacker88_pos.x+1 == me_pos.x) &&(attacker88_pos.y-1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 585 | (attacker88_pos.x+1 == me_pos.x) &&(attacker88_pos.y-2 == me_pos.y) //left |
dongyuhu | 0:9e95a5ef2659 | 586 | ) |
dongyuhu | 0:9e95a5ef2659 | 587 | { |
dongyuhu | 0:9e95a5ef2659 | 588 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 589 | attacker88_pos.x=74; |
dongyuhu | 0:9e95a5ef2659 | 590 | attacker88_pos.y=17; |
dongyuhu | 0:9e95a5ef2659 | 591 | } |
dongyuhu | 0:9e95a5ef2659 | 592 | if ((attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y+1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 593 | (attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 594 | (attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y-1 == me_pos.y)|| |
dongyuhu | 0:9e95a5ef2659 | 595 | (attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y-2 == me_pos.y) //right |
dongyuhu | 0:9e95a5ef2659 | 596 | ) |
dongyuhu | 0:9e95a5ef2659 | 597 | { |
dongyuhu | 0:9e95a5ef2659 | 598 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 599 | attacker88_pos.x=74; |
dongyuhu | 0:9e95a5ef2659 | 600 | attacker88_pos.y=17; |
dongyuhu | 0:9e95a5ef2659 | 601 | } |
dongyuhu | 0:9e95a5ef2659 | 602 | if ((attacker88_pos.x == me_pos.x-1) &&(attacker88_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 603 | (attacker88_pos.x == me_pos.x ) &&(attacker88_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 604 | (attacker88_pos.x == me_pos.x+1) &&(attacker88_pos.y+2 == me_pos.y+1)|| |
dongyuhu | 0:9e95a5ef2659 | 605 | (attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y+2 == me_pos.y+1) //up |
dongyuhu | 0:9e95a5ef2659 | 606 | ) |
dongyuhu | 0:9e95a5ef2659 | 607 | { |
dongyuhu | 0:9e95a5ef2659 | 608 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 609 | attacker88_pos.x=74; |
dongyuhu | 0:9e95a5ef2659 | 610 | attacker88_pos.y=17; |
dongyuhu | 0:9e95a5ef2659 | 611 | } |
dongyuhu | 0:9e95a5ef2659 | 612 | if ((attacker88_pos.x == me_pos.x-1) &&(attacker88_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 613 | (attacker88_pos.x == me_pos.x ) &&(attacker88_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 614 | (attacker88_pos.x == me_pos.x+1) &&(attacker88_pos.y == me_pos.y+2)|| |
dongyuhu | 0:9e95a5ef2659 | 615 | (attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y == me_pos.y+2) //down |
dongyuhu | 0:9e95a5ef2659 | 616 | ) |
dongyuhu | 0:9e95a5ef2659 | 617 | { |
dongyuhu | 0:9e95a5ef2659 | 618 | ifnotstop = false; |
dongyuhu | 0:9e95a5ef2659 | 619 | attacker88_pos.x=74; |
dongyuhu | 0:9e95a5ef2659 | 620 | attacker88_pos.y=17; |
dongyuhu | 0:9e95a5ef2659 | 621 | } |
dongyuhu | 0:9e95a5ef2659 | 622 | |
dongyuhu | 0:9e95a5ef2659 | 623 | _attacker1.set_pos(attacker11_pos); |
dongyuhu | 0:9e95a5ef2659 | 624 | _attacker2.set_pos(attacker22_pos); |
dongyuhu | 0:9e95a5ef2659 | 625 | _attacker3.set_pos(attacker33_pos); |
dongyuhu | 0:9e95a5ef2659 | 626 | _attacker4.set_pos(attacker44_pos); |
dongyuhu | 0:9e95a5ef2659 | 627 | _attacker5.set_pos(attacker55_pos); |
dongyuhu | 0:9e95a5ef2659 | 628 | _attacker6.set_pos(attacker66_pos); |
dongyuhu | 0:9e95a5ef2659 | 629 | _attacker7.set_pos(attacker77_pos); |
dongyuhu | 0:9e95a5ef2659 | 630 | _attacker8.set_pos(attacker88_pos); |
dongyuhu | 0:9e95a5ef2659 | 631 | |
dongyuhu | 0:9e95a5ef2659 | 632 | } |