publish my project

Dependencies:   mbed

Committer:
dongyuhu
Date:
Mon Apr 27 12:13:02 2020 +0000
Revision:
4:fd47d9c11263
Parent:
3:c89450845b2a
Child:
5:c31ba165e49c
Second change of Attacker

Who changed what in which revision?

UserRevisionLine numberNew 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 3:c89450845b2a 85 void setpos(Vector2D attacker_pos,int x,int y)
dongyuhu 3:c89450845b2a 86 {
dongyuhu 3:c89450845b2a 87 attacker_pos.x=x;
dongyuhu 3:c89450845b2a 88 attacker_pos.y=y;
dongyuhu 3:c89450845b2a 89 }
dongyuhu 3:c89450845b2a 90
dongyuhu 3:c89450845b2a 91 void JUDGE(Vector2D attacker11_pos,Vector2D attacker22_pos,Vector2D attacker33_pos,Vector2D attacker44_pos,Vector2D attacker55_pos,Vector2D attacker66_pos,Vector2D attacker77_pos,Vector2D attacker88_pos)
dongyuhu 3:c89450845b2a 92 {
dongyuhu 4:fd47d9c11263 93 if(attacker11_pos.y < 10||attacker11_pos.y > 36||attacker11_pos.x < 10||attacker11_pos.x > 72)
dongyuhu 3:c89450845b2a 94 setpos(attacker11_pos,30,11);
dongyuhu 3:c89450845b2a 95 else if(attacker22_pos.y < 10||attacker22_pos.y > 36||attacker22_pos.x < 10||attacker22_pos.x > 72)
dongyuhu 3:c89450845b2a 96 setpos(attacker22_pos,54,10);
dongyuhu 3:c89450845b2a 97 else if(attacker33_pos.y < 10||attacker33_pos.y > 36||attacker33_pos.x < 10||attacker33_pos.x > 72)
dongyuhu 3:c89450845b2a 98 setpos(attacker33_pos,10,17);
dongyuhu 3:c89450845b2a 99 else if(attacker44_pos.y < 10||attacker44_pos.y > 36||attacker11_pos.x < 10||attacker44_pos.x > 72)
dongyuhu 3:c89450845b2a 100 setpos(attacker44_pos,10,31);
dongyuhu 3:c89450845b2a 101 else if(attacker55_pos.y < 10||attacker55_pos.y > 36||attacker55_pos.x < 10||attacker55_pos.x > 72)
dongyuhu 3:c89450845b2a 102 setpos(attacker55_pos,30,36);
dongyuhu 3:c89450845b2a 103 else if(attacker66_pos.y < 10||attacker66_pos.y > 36||attacker66_pos.x < 10||attacker66_pos.x >72)
dongyuhu 3:c89450845b2a 104 setpos(attacker66_pos,54,36);
dongyuhu 3:c89450845b2a 105 else if(attacker77_pos.y < 10||attacker77_pos.y > 36||attacker77_pos.x < 10||attacker77_pos.x >72)
dongyuhu 3:c89450845b2a 106 setpos(attacker77_pos,71,31);
dongyuhu 3:c89450845b2a 107 else if(attacker88_pos.y < 10||attacker88_pos.y > 36||attacker88_pos.x < 10||attacker88_pos.x >72)
dongyuhu 3:c89450845b2a 108 setpos(attacker77_pos,71,17);
dongyuhu 3:c89450845b2a 109 }
dongyuhu 0:9e95a5ef2659 110
dongyuhu 0:9e95a5ef2659 111 void Start::check_wall_collision(Gamepad &pad)
dongyuhu 0:9e95a5ef2659 112 {
dongyuhu 0:9e95a5ef2659 113 Vector2D attacker11_pos = _attacker1.get_pos();
dongyuhu 0:9e95a5ef2659 114 Vector2D attacker22_pos = _attacker2.get_pos();
dongyuhu 0:9e95a5ef2659 115 Vector2D attacker33_pos = _attacker3.get_pos();
dongyuhu 0:9e95a5ef2659 116 Vector2D attacker44_pos = _attacker4.get_pos();
dongyuhu 0:9e95a5ef2659 117 Vector2D attacker55_pos = _attacker5.get_pos();
dongyuhu 0:9e95a5ef2659 118 Vector2D attacker66_pos = _attacker6.get_pos();
dongyuhu 0:9e95a5ef2659 119 Vector2D attacker77_pos = _attacker7.get_pos();
dongyuhu 0:9e95a5ef2659 120 Vector2D attacker88_pos = _attacker8.get_pos();
dongyuhu 0:9e95a5ef2659 121
dongyuhu 3:c89450845b2a 122 JUDGE(attacker11_pos,attacker22_pos,attacker33_pos,attacker44_pos,attacker55_pos,attacker66_pos,attacker77_pos,attacker88_pos);
dongyuhu 3:c89450845b2a 123
dongyuhu 0:9e95a5ef2659 124 _attacker1.set_pos(attacker11_pos);
dongyuhu 0:9e95a5ef2659 125 _attacker2.set_pos(attacker22_pos);
dongyuhu 0:9e95a5ef2659 126 _attacker3.set_pos(attacker33_pos);
dongyuhu 0:9e95a5ef2659 127 _attacker4.set_pos(attacker44_pos);
dongyuhu 0:9e95a5ef2659 128 _attacker5.set_pos(attacker55_pos);
dongyuhu 0:9e95a5ef2659 129 _attacker6.set_pos(attacker66_pos);
dongyuhu 0:9e95a5ef2659 130 _attacker7.set_pos(attacker77_pos);
dongyuhu 0:9e95a5ef2659 131 _attacker8.set_pos(attacker88_pos);
dongyuhu 0:9e95a5ef2659 132
dongyuhu 0:9e95a5ef2659 133 }
dongyuhu 0:9e95a5ef2659 134
dongyuhu 0:9e95a5ef2659 135
dongyuhu 0:9e95a5ef2659 136 void Start::check_body_collisions(Gamepad &pad)
dongyuhu 0:9e95a5ef2659 137 {
dongyuhu 0:9e95a5ef2659 138 Vector2D attacker11_pos = _attacker1.get_pos();
dongyuhu 0:9e95a5ef2659 139 Vector2D attacker22_pos = _attacker2.get_pos();
dongyuhu 0:9e95a5ef2659 140 Vector2D attacker33_pos = _attacker3.get_pos();
dongyuhu 0:9e95a5ef2659 141 Vector2D attacker44_pos = _attacker4.get_pos();
dongyuhu 0:9e95a5ef2659 142 Vector2D attacker55_pos = _attacker5.get_pos();
dongyuhu 0:9e95a5ef2659 143 Vector2D attacker66_pos = _attacker6.get_pos();
dongyuhu 0:9e95a5ef2659 144 Vector2D attacker77_pos = _attacker7.get_pos();
dongyuhu 0:9e95a5ef2659 145 Vector2D attacker88_pos = _attacker8.get_pos();
dongyuhu 0:9e95a5ef2659 146
dongyuhu 0:9e95a5ef2659 147
dongyuhu 0:9e95a5ef2659 148 Vector2D me_pos = _me.get_pos();
dongyuhu 0:9e95a5ef2659 149 if ((attacker11_pos.x+1 == me_pos.x) &&(attacker11_pos.y+1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 150 (attacker11_pos.x+1 == me_pos.x) &&(attacker11_pos.y == me_pos.y)||
dongyuhu 0:9e95a5ef2659 151 (attacker11_pos.x+1 == me_pos.x) &&(attacker11_pos.y-1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 152 (attacker11_pos.x+1 == me_pos.x) &&(attacker11_pos.y-2 == me_pos.y) //if attacker collides me from left
dongyuhu 0:9e95a5ef2659 153 )
dongyuhu 0:9e95a5ef2659 154 {
dongyuhu 0:9e95a5ef2659 155 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 156 attacker11_pos.x=30; //attacker back to initial position
dongyuhu 0:9e95a5ef2659 157 attacker11_pos.y=11;
dongyuhu 0:9e95a5ef2659 158 }
dongyuhu 0:9e95a5ef2659 159 if ((attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y+1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 160 (attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y == me_pos.y)||
dongyuhu 0:9e95a5ef2659 161 (attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y-1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 162 (attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y-2 == me_pos.y) //right
dongyuhu 0:9e95a5ef2659 163 )
dongyuhu 0:9e95a5ef2659 164 {
dongyuhu 0:9e95a5ef2659 165 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 166 attacker11_pos.x=30;
dongyuhu 0:9e95a5ef2659 167 attacker11_pos.y=11;
dongyuhu 0:9e95a5ef2659 168 }
dongyuhu 0:9e95a5ef2659 169 if ((attacker11_pos.x == me_pos.x-1) &&(attacker11_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 170 (attacker11_pos.x == me_pos.x ) &&(attacker11_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 171 (attacker11_pos.x == me_pos.x+1) &&(attacker11_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 172 (attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y+2 == me_pos.y+1) //up
dongyuhu 0:9e95a5ef2659 173 )
dongyuhu 0:9e95a5ef2659 174 {
dongyuhu 0:9e95a5ef2659 175 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 176 attacker11_pos.x=30;
dongyuhu 0:9e95a5ef2659 177 attacker11_pos.y=11;
dongyuhu 0:9e95a5ef2659 178 }
dongyuhu 0:9e95a5ef2659 179 if ((attacker11_pos.x == me_pos.x-1) &&(attacker11_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 180 (attacker11_pos.x == me_pos.x ) &&(attacker11_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 181 (attacker11_pos.x == me_pos.x+1) &&(attacker11_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 182 (attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y == me_pos.y+2) //down
dongyuhu 0:9e95a5ef2659 183 )
dongyuhu 0:9e95a5ef2659 184 {
dongyuhu 0:9e95a5ef2659 185 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 186 attacker11_pos.x=30;
dongyuhu 0:9e95a5ef2659 187 attacker11_pos.y=11;
dongyuhu 0:9e95a5ef2659 188 }
dongyuhu 0:9e95a5ef2659 189 /////////////////////////////////////////////////////////////////////////////////////////////////
dongyuhu 0:9e95a5ef2659 190
dongyuhu 0:9e95a5ef2659 191 if ((attacker22_pos.x+1 == me_pos.x) &&(attacker22_pos.y+1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 192 (attacker22_pos.x+1 == me_pos.x) &&(attacker22_pos.y == me_pos.y)||
dongyuhu 0:9e95a5ef2659 193 (attacker22_pos.x+1 == me_pos.x) &&(attacker22_pos.y-1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 194 (attacker22_pos.x+1 == me_pos.x) &&(attacker22_pos.y-2 == me_pos.y) //left
dongyuhu 0:9e95a5ef2659 195 )
dongyuhu 0:9e95a5ef2659 196 {
dongyuhu 0:9e95a5ef2659 197 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 198 attacker22_pos.x=54;
dongyuhu 0:9e95a5ef2659 199 attacker22_pos.y=10;
dongyuhu 0:9e95a5ef2659 200 }
dongyuhu 0:9e95a5ef2659 201 if ((attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y+1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 202 (attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y == me_pos.y)||
dongyuhu 0:9e95a5ef2659 203 (attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y-1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 204 (attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y-2 == me_pos.y) //right
dongyuhu 0:9e95a5ef2659 205 )
dongyuhu 0:9e95a5ef2659 206 {
dongyuhu 0:9e95a5ef2659 207 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 208 attacker22_pos.x=54;
dongyuhu 0:9e95a5ef2659 209 attacker22_pos.y=10;
dongyuhu 0:9e95a5ef2659 210 }
dongyuhu 0:9e95a5ef2659 211 if ((attacker22_pos.x == me_pos.x-1) &&(attacker22_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 212 (attacker22_pos.x == me_pos.x ) &&(attacker22_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 213 (attacker22_pos.x == me_pos.x+1) &&(attacker22_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 214 (attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y+2 == me_pos.y+1) //up
dongyuhu 0:9e95a5ef2659 215 )
dongyuhu 0:9e95a5ef2659 216 {
dongyuhu 0:9e95a5ef2659 217 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 218 attacker22_pos.x=54;
dongyuhu 0:9e95a5ef2659 219 attacker22_pos.y=10;
dongyuhu 0:9e95a5ef2659 220 }
dongyuhu 0:9e95a5ef2659 221 if ((attacker22_pos.x == me_pos.x-1) &&(attacker22_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 222 (attacker22_pos.x == me_pos.x ) &&(attacker22_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 223 (attacker22_pos.x == me_pos.x+1) &&(attacker22_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 224 (attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y == me_pos.y+2) //down
dongyuhu 0:9e95a5ef2659 225 )
dongyuhu 0:9e95a5ef2659 226 {
dongyuhu 0:9e95a5ef2659 227 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 228 attacker22_pos.x=54;
dongyuhu 0:9e95a5ef2659 229 attacker22_pos.y=10;
dongyuhu 0:9e95a5ef2659 230 }
dongyuhu 0:9e95a5ef2659 231 /////////////////////////////////////////////////////////////////
dongyuhu 0:9e95a5ef2659 232 if ((attacker33_pos.x+1 == me_pos.x) &&(attacker33_pos.y+1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 233 (attacker33_pos.x+1 == me_pos.x) &&(attacker33_pos.y == me_pos.y)||
dongyuhu 0:9e95a5ef2659 234 (attacker33_pos.x+1 == me_pos.x) &&(attacker33_pos.y-1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 235 (attacker33_pos.x+1 == me_pos.x) &&(attacker33_pos.y-2 == me_pos.y) //left
dongyuhu 0:9e95a5ef2659 236 )
dongyuhu 0:9e95a5ef2659 237 {
dongyuhu 0:9e95a5ef2659 238 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 239 attacker33_pos.x=10;
dongyuhu 0:9e95a5ef2659 240 attacker33_pos.y=17;
dongyuhu 0:9e95a5ef2659 241 }
dongyuhu 0:9e95a5ef2659 242 if ((attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y+1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 243 (attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y == me_pos.y)||
dongyuhu 0:9e95a5ef2659 244 (attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y-1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 245 (attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y-2 == me_pos.y) //right
dongyuhu 0:9e95a5ef2659 246 )
dongyuhu 0:9e95a5ef2659 247 {
dongyuhu 0:9e95a5ef2659 248 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 249 attacker33_pos.x=10;
dongyuhu 0:9e95a5ef2659 250 attacker33_pos.y=17;
dongyuhu 0:9e95a5ef2659 251 }
dongyuhu 0:9e95a5ef2659 252 if ((attacker33_pos.x == me_pos.x-1) &&(attacker33_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 253 (attacker33_pos.x == me_pos.x ) &&(attacker33_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 254 (attacker33_pos.x == me_pos.x+1) &&(attacker33_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 255 (attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y+2 == me_pos.y+1) //up
dongyuhu 0:9e95a5ef2659 256 )
dongyuhu 0:9e95a5ef2659 257 {
dongyuhu 0:9e95a5ef2659 258 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 259 attacker33_pos.x=10;
dongyuhu 0:9e95a5ef2659 260 attacker33_pos.y=17;
dongyuhu 0:9e95a5ef2659 261 }
dongyuhu 0:9e95a5ef2659 262 if ((attacker33_pos.x == me_pos.x-1) &&(attacker33_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 263 (attacker33_pos.x == me_pos.x ) &&(attacker33_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 264 (attacker33_pos.x == me_pos.x+1) &&(attacker33_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 265 (attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y == me_pos.y+2) //down
dongyuhu 0:9e95a5ef2659 266 )
dongyuhu 0:9e95a5ef2659 267 {
dongyuhu 0:9e95a5ef2659 268 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 269 attacker33_pos.x=10;
dongyuhu 0:9e95a5ef2659 270 attacker33_pos.y=17;
dongyuhu 0:9e95a5ef2659 271 }
dongyuhu 0:9e95a5ef2659 272 /////////////////////////////////////////////////////////////////////////////////////////////////
dongyuhu 0:9e95a5ef2659 273
dongyuhu 0:9e95a5ef2659 274 if ((attacker44_pos.x+1 == me_pos.x) &&(attacker44_pos.y+1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 275 (attacker44_pos.x+1 == me_pos.x) &&(attacker44_pos.y == me_pos.y)||
dongyuhu 0:9e95a5ef2659 276 (attacker44_pos.x+1 == me_pos.x) &&(attacker44_pos.y-1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 277 (attacker44_pos.x+1 == me_pos.x) &&(attacker44_pos.y-2 == me_pos.y) //left
dongyuhu 0:9e95a5ef2659 278 )
dongyuhu 0:9e95a5ef2659 279 {
dongyuhu 0:9e95a5ef2659 280 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 281 attacker44_pos.x=10;
dongyuhu 0:9e95a5ef2659 282 attacker44_pos.y=31;
dongyuhu 0:9e95a5ef2659 283 }
dongyuhu 0:9e95a5ef2659 284 if ((attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y+1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 285 (attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y == me_pos.y)||
dongyuhu 0:9e95a5ef2659 286 (attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y-1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 287 (attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y-2 == me_pos.y) //right
dongyuhu 0:9e95a5ef2659 288 )
dongyuhu 0:9e95a5ef2659 289 {
dongyuhu 0:9e95a5ef2659 290 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 291 attacker44_pos.x=10;
dongyuhu 0:9e95a5ef2659 292 attacker44_pos.y=31;
dongyuhu 0:9e95a5ef2659 293 }
dongyuhu 0:9e95a5ef2659 294 if ((attacker44_pos.x == me_pos.x-1) &&(attacker44_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 295 (attacker44_pos.x == me_pos.x ) &&(attacker44_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 296 (attacker44_pos.x == me_pos.x+1) &&(attacker44_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 297 (attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y+2 == me_pos.y+1) //up
dongyuhu 0:9e95a5ef2659 298 )
dongyuhu 0:9e95a5ef2659 299 {
dongyuhu 0:9e95a5ef2659 300 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 301 attacker44_pos.x=10;
dongyuhu 0:9e95a5ef2659 302 attacker44_pos.y=31;
dongyuhu 0:9e95a5ef2659 303 }
dongyuhu 0:9e95a5ef2659 304 if ((attacker44_pos.x == me_pos.x-1) &&(attacker44_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 305 (attacker44_pos.x == me_pos.x ) &&(attacker44_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 306 (attacker44_pos.x == me_pos.x+1) &&(attacker44_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 307 (attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y == me_pos.y+2) //down
dongyuhu 0:9e95a5ef2659 308 )
dongyuhu 0:9e95a5ef2659 309 {
dongyuhu 0:9e95a5ef2659 310 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 311 attacker44_pos.x=10;
dongyuhu 0:9e95a5ef2659 312 attacker44_pos.y=31;
dongyuhu 0:9e95a5ef2659 313 }
dongyuhu 0:9e95a5ef2659 314 ///////////////////////////////////////////////////////////////////
dongyuhu 0:9e95a5ef2659 315 if ((attacker55_pos.x+1 == me_pos.x) &&(attacker55_pos.y+1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 316 (attacker55_pos.x+1 == me_pos.x) &&(attacker55_pos.y == me_pos.y)||
dongyuhu 0:9e95a5ef2659 317 (attacker55_pos.x+1 == me_pos.x) &&(attacker55_pos.y-1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 318 (attacker55_pos.x+1 == me_pos.x) &&(attacker55_pos.y-2 == me_pos.y) //left
dongyuhu 0:9e95a5ef2659 319 )
dongyuhu 0:9e95a5ef2659 320 {
dongyuhu 0:9e95a5ef2659 321 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 322 attacker55_pos.x=30;
dongyuhu 0:9e95a5ef2659 323 attacker55_pos.y=38;
dongyuhu 0:9e95a5ef2659 324 }
dongyuhu 0:9e95a5ef2659 325 if ((attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y+1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 326 (attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y == me_pos.y)||
dongyuhu 0:9e95a5ef2659 327 (attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y-1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 328 (attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y-2 == me_pos.y) //right
dongyuhu 0:9e95a5ef2659 329 )
dongyuhu 0:9e95a5ef2659 330 {
dongyuhu 0:9e95a5ef2659 331 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 332 attacker11_pos.x=30;
dongyuhu 0:9e95a5ef2659 333 attacker11_pos.y=38;
dongyuhu 0:9e95a5ef2659 334 }
dongyuhu 0:9e95a5ef2659 335 if ((attacker55_pos.x == me_pos.x-1) &&(attacker55_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 336 (attacker55_pos.x == me_pos.x ) &&(attacker55_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 337 (attacker55_pos.x == me_pos.x+1) &&(attacker55_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 338 (attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y+2 == me_pos.y+1) //up
dongyuhu 0:9e95a5ef2659 339 )
dongyuhu 0:9e95a5ef2659 340 {
dongyuhu 0:9e95a5ef2659 341 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 342 attacker55_pos.x=30;
dongyuhu 0:9e95a5ef2659 343 attacker55_pos.y=38;
dongyuhu 0:9e95a5ef2659 344 }
dongyuhu 0:9e95a5ef2659 345 if ((attacker55_pos.x == me_pos.x-1) &&(attacker55_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 346 (attacker55_pos.x == me_pos.x ) &&(attacker55_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 347 (attacker55_pos.x == me_pos.x+1) &&(attacker55_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 348 (attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y == me_pos.y+2) //down
dongyuhu 0:9e95a5ef2659 349 )
dongyuhu 0:9e95a5ef2659 350 {
dongyuhu 0:9e95a5ef2659 351 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 352 attacker55_pos.x=30;
dongyuhu 0:9e95a5ef2659 353 attacker55_pos.y=38;
dongyuhu 0:9e95a5ef2659 354 }
dongyuhu 0:9e95a5ef2659 355 /////////////////////////////////////////////////////////////////////////////////////////////////
dongyuhu 0:9e95a5ef2659 356
dongyuhu 0:9e95a5ef2659 357 if ((attacker66_pos.x+1 == me_pos.x) &&(attacker66_pos.y+1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 358 (attacker66_pos.x+1 == me_pos.x) &&(attacker66_pos.y == me_pos.y)||
dongyuhu 0:9e95a5ef2659 359 (attacker66_pos.x+1 == me_pos.x) &&(attacker66_pos.y-1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 360 (attacker66_pos.x+1 == me_pos.x) &&(attacker66_pos.y-2 == me_pos.y) //left
dongyuhu 0:9e95a5ef2659 361 )
dongyuhu 0:9e95a5ef2659 362 {
dongyuhu 0:9e95a5ef2659 363 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 364 attacker66_pos.x=54;
dongyuhu 0:9e95a5ef2659 365 attacker66_pos.y=38;
dongyuhu 0:9e95a5ef2659 366 }
dongyuhu 0:9e95a5ef2659 367 if ((attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y+1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 368 (attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y == me_pos.y)||
dongyuhu 0:9e95a5ef2659 369 (attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y-1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 370 (attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y-2 == me_pos.y) //right
dongyuhu 0:9e95a5ef2659 371 )
dongyuhu 0:9e95a5ef2659 372 {
dongyuhu 0:9e95a5ef2659 373 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 374 attacker66_pos.x=54;
dongyuhu 0:9e95a5ef2659 375 attacker66_pos.y=38;
dongyuhu 0:9e95a5ef2659 376 }
dongyuhu 0:9e95a5ef2659 377 if ((attacker66_pos.x == me_pos.x-1) &&(attacker66_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 378 (attacker66_pos.x == me_pos.x ) &&(attacker66_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 379 (attacker66_pos.x == me_pos.x+1) &&(attacker66_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 380 (attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y+2 == me_pos.y+1) //up
dongyuhu 0:9e95a5ef2659 381 )
dongyuhu 0:9e95a5ef2659 382 {
dongyuhu 0:9e95a5ef2659 383 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 384 attacker66_pos.x=54;
dongyuhu 0:9e95a5ef2659 385 attacker66_pos.y=38;
dongyuhu 0:9e95a5ef2659 386 }
dongyuhu 0:9e95a5ef2659 387 if ((attacker66_pos.x == me_pos.x-1) &&(attacker66_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 388 (attacker66_pos.x == me_pos.x ) &&(attacker66_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 389 (attacker66_pos.x == me_pos.x+1) &&(attacker66_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 390 (attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y == me_pos.y+2) //down
dongyuhu 0:9e95a5ef2659 391 )
dongyuhu 0:9e95a5ef2659 392 {
dongyuhu 0:9e95a5ef2659 393 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 394 attacker66_pos.x=54;
dongyuhu 0:9e95a5ef2659 395 attacker66_pos.y=38;
dongyuhu 0:9e95a5ef2659 396 }
dongyuhu 0:9e95a5ef2659 397 ///////////////////////////////////////////////////////
dongyuhu 0:9e95a5ef2659 398 if ((attacker77_pos.x+1 == me_pos.x) &&(attacker77_pos.y+1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 399 (attacker77_pos.x+1 == me_pos.x) &&(attacker77_pos.y == me_pos.y)||
dongyuhu 0:9e95a5ef2659 400 (attacker77_pos.x+1 == me_pos.x) &&(attacker77_pos.y-1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 401 (attacker77_pos.x+1 == me_pos.x) &&(attacker77_pos.y-2 == me_pos.y) //left
dongyuhu 0:9e95a5ef2659 402 )
dongyuhu 0:9e95a5ef2659 403 {
dongyuhu 0:9e95a5ef2659 404 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 405 attacker77_pos.x=74;
dongyuhu 0:9e95a5ef2659 406 attacker77_pos.y=31;
dongyuhu 0:9e95a5ef2659 407 }
dongyuhu 0:9e95a5ef2659 408 if ((attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y+1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 409 (attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y == me_pos.y)||
dongyuhu 0:9e95a5ef2659 410 (attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y-1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 411 (attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y-2 == me_pos.y) //right
dongyuhu 0:9e95a5ef2659 412 )
dongyuhu 0:9e95a5ef2659 413 {
dongyuhu 0:9e95a5ef2659 414 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 415 attacker77_pos.x=74;
dongyuhu 0:9e95a5ef2659 416 attacker77_pos.y=31;
dongyuhu 0:9e95a5ef2659 417 }
dongyuhu 0:9e95a5ef2659 418 if ((attacker77_pos.x == me_pos.x-1) &&(attacker77_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 419 (attacker77_pos.x == me_pos.x ) &&(attacker77_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 420 (attacker77_pos.x == me_pos.x+1) &&(attacker77_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 421 (attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y+2 == me_pos.y+1) //up
dongyuhu 0:9e95a5ef2659 422 )
dongyuhu 0:9e95a5ef2659 423 {
dongyuhu 0:9e95a5ef2659 424 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 425 attacker77_pos.x=74;
dongyuhu 0:9e95a5ef2659 426 attacker77_pos.y=31;
dongyuhu 0:9e95a5ef2659 427 }
dongyuhu 0:9e95a5ef2659 428 if ((attacker77_pos.x == me_pos.x-1) &&(attacker77_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 429 (attacker77_pos.x == me_pos.x ) &&(attacker77_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 430 (attacker77_pos.x == me_pos.x+1) &&(attacker77_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 431 (attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y == me_pos.y+2) //down
dongyuhu 0:9e95a5ef2659 432 )
dongyuhu 0:9e95a5ef2659 433 {
dongyuhu 0:9e95a5ef2659 434 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 435 attacker77_pos.x=74;
dongyuhu 0:9e95a5ef2659 436 attacker77_pos.y=31;
dongyuhu 0:9e95a5ef2659 437 }
dongyuhu 0:9e95a5ef2659 438 /////////////////////////////////////////////////////////////////////////////////////////////////
dongyuhu 0:9e95a5ef2659 439
dongyuhu 0:9e95a5ef2659 440 if ((attacker88_pos.x+1 == me_pos.x) &&(attacker88_pos.y+1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 441 (attacker88_pos.x+1 == me_pos.x) &&(attacker88_pos.y == me_pos.y)||
dongyuhu 0:9e95a5ef2659 442 (attacker88_pos.x+1 == me_pos.x) &&(attacker88_pos.y-1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 443 (attacker88_pos.x+1 == me_pos.x) &&(attacker88_pos.y-2 == me_pos.y) //left
dongyuhu 0:9e95a5ef2659 444 )
dongyuhu 0:9e95a5ef2659 445 {
dongyuhu 0:9e95a5ef2659 446 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 447 attacker88_pos.x=74;
dongyuhu 0:9e95a5ef2659 448 attacker88_pos.y=17;
dongyuhu 0:9e95a5ef2659 449 }
dongyuhu 0:9e95a5ef2659 450 if ((attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y+1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 451 (attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y == me_pos.y)||
dongyuhu 0:9e95a5ef2659 452 (attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y-1 == me_pos.y)||
dongyuhu 0:9e95a5ef2659 453 (attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y-2 == me_pos.y) //right
dongyuhu 0:9e95a5ef2659 454 )
dongyuhu 0:9e95a5ef2659 455 {
dongyuhu 0:9e95a5ef2659 456 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 457 attacker88_pos.x=74;
dongyuhu 0:9e95a5ef2659 458 attacker88_pos.y=17;
dongyuhu 0:9e95a5ef2659 459 }
dongyuhu 0:9e95a5ef2659 460 if ((attacker88_pos.x == me_pos.x-1) &&(attacker88_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 461 (attacker88_pos.x == me_pos.x ) &&(attacker88_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 462 (attacker88_pos.x == me_pos.x+1) &&(attacker88_pos.y+2 == me_pos.y+1)||
dongyuhu 0:9e95a5ef2659 463 (attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y+2 == me_pos.y+1) //up
dongyuhu 0:9e95a5ef2659 464 )
dongyuhu 0:9e95a5ef2659 465 {
dongyuhu 0:9e95a5ef2659 466 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 467 attacker88_pos.x=74;
dongyuhu 0:9e95a5ef2659 468 attacker88_pos.y=17;
dongyuhu 0:9e95a5ef2659 469 }
dongyuhu 0:9e95a5ef2659 470 if ((attacker88_pos.x == me_pos.x-1) &&(attacker88_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 471 (attacker88_pos.x == me_pos.x ) &&(attacker88_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 472 (attacker88_pos.x == me_pos.x+1) &&(attacker88_pos.y == me_pos.y+2)||
dongyuhu 0:9e95a5ef2659 473 (attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y == me_pos.y+2) //down
dongyuhu 0:9e95a5ef2659 474 )
dongyuhu 0:9e95a5ef2659 475 {
dongyuhu 0:9e95a5ef2659 476 ifnotstop = false;
dongyuhu 0:9e95a5ef2659 477 attacker88_pos.x=74;
dongyuhu 0:9e95a5ef2659 478 attacker88_pos.y=17;
dongyuhu 0:9e95a5ef2659 479 }
dongyuhu 0:9e95a5ef2659 480
dongyuhu 0:9e95a5ef2659 481 _attacker1.set_pos(attacker11_pos);
dongyuhu 0:9e95a5ef2659 482 _attacker2.set_pos(attacker22_pos);
dongyuhu 0:9e95a5ef2659 483 _attacker3.set_pos(attacker33_pos);
dongyuhu 0:9e95a5ef2659 484 _attacker4.set_pos(attacker44_pos);
dongyuhu 0:9e95a5ef2659 485 _attacker5.set_pos(attacker55_pos);
dongyuhu 0:9e95a5ef2659 486 _attacker6.set_pos(attacker66_pos);
dongyuhu 0:9e95a5ef2659 487 _attacker7.set_pos(attacker77_pos);
dongyuhu 0:9e95a5ef2659 488 _attacker8.set_pos(attacker88_pos);
dongyuhu 0:9e95a5ef2659 489
dongyuhu 0:9e95a5ef2659 490 }