publish my project

Dependencies:   mbed

Revision:
5:c31ba165e49c
Parent:
4:fd47d9c11263
--- a/Start/Start.cpp	Mon Apr 27 12:13:02 2020 +0000
+++ b/Start/Start.cpp	Tue Apr 28 04:39:12 2020 +0000
@@ -82,13 +82,14 @@
     check_body_collisions(pad);
 
 }
-void setpos(Vector2D attacker_pos,int x,int y)
+void setpos(Vector2D &attacker_pos,int x,int y)
 {
-     attacker_pos.x=x;        
-     attacker_pos.y=y;
+     attacker_pos.x = x;        
+     attacker_pos.y = y;
 }
 
-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)
+
+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)
 {
     if(attacker11_pos.y < 10||attacker11_pos.y > 36||attacker11_pos.x < 10||attacker11_pos.x > 72) 
         setpos(attacker11_pos,30,11);  
@@ -105,7 +106,7 @@
     else if(attacker77_pos.y < 10||attacker77_pos.y > 36||attacker77_pos.x < 10||attacker77_pos.x >72)
         setpos(attacker77_pos,71,31);
     else if(attacker88_pos.y < 10||attacker88_pos.y > 36||attacker88_pos.x < 10||attacker88_pos.x >72)
-        setpos(attacker77_pos,71,17);
+        setpos(attacker88_pos,71,17);
 }
 
 void Start::check_wall_collision(Gamepad &pad)
@@ -118,9 +119,7 @@
     Vector2D attacker66_pos = _attacker6.get_pos();
     Vector2D attacker77_pos = _attacker7.get_pos();
     Vector2D attacker88_pos = _attacker8.get_pos();
-
-    JUDGE(attacker11_pos,attacker22_pos,attacker33_pos,attacker44_pos,attacker55_pos,attacker66_pos,attacker77_pos,attacker88_pos);
-       
+    JUDGE(attacker11_pos,attacker22_pos,attacker33_pos,attacker44_pos,attacker55_pos,attacker66_pos,attacker77_pos,attacker88_pos);   
     _attacker1.set_pos(attacker11_pos);
     _attacker2.set_pos(attacker22_pos);
     _attacker3.set_pos(attacker33_pos);
@@ -131,353 +130,67 @@
     _attacker8.set_pos(attacker88_pos);
 
 }
+void set_stop(Vector2D &attacker_pos,int x,int y)
+{
+    ifnotstop = false;
+    attacker_pos.x = x;
+    attacker_pos.y = y;
+}
+bool Judge_for_each_situation(Vector2D &me_pos,Vector2D &attacker_pos)
+{
+      if ((attacker_pos.x+1 == me_pos.x) &&(attacker_pos.y+1 == me_pos.y)||
+          (attacker_pos.x+1 == me_pos.x) &&(attacker_pos.y   == me_pos.y)||
+          (attacker_pos.x+1 == me_pos.x) &&(attacker_pos.y-1 == me_pos.y)||  
+          (attacker_pos.x+1 == me_pos.x) &&(attacker_pos.y-2 == me_pos.y)|| 
+          (attacker_pos.x == me_pos.x+2) &&(attacker_pos.y+1 == me_pos.y)||
+          (attacker_pos.x == me_pos.x+2) &&(attacker_pos.y   == me_pos.y)||
+          (attacker_pos.x == me_pos.x+2) &&(attacker_pos.y-1 == me_pos.y)||  
+          (attacker_pos.x == me_pos.x+2) &&(attacker_pos.y-2 == me_pos.y)||
+          (attacker_pos.x == me_pos.x-1) &&(attacker_pos.y+2 == me_pos.y+1)||
+          (attacker_pos.x == me_pos.x  ) &&(attacker_pos.y+2 == me_pos.y+1)||
+          (attacker_pos.x == me_pos.x+1) &&(attacker_pos.y+2 == me_pos.y+1)||  
+          (attacker_pos.x == me_pos.x+2) &&(attacker_pos.y+2 == me_pos.y+1)||
+          (attacker_pos.x == me_pos.x-1) &&(attacker_pos.y == me_pos.y+2)||
+          (attacker_pos.x == me_pos.x  ) &&(attacker_pos.y == me_pos.y+2)||
+          (attacker_pos.x == me_pos.x+1) &&(attacker_pos.y == me_pos.y+2)||  
+          (attacker_pos.x == me_pos.x+2) &&(attacker_pos.y == me_pos.y+2))
+          return true;
+      else
+          return false;
+}
+void Judge_ifstop(Vector2D &me_pos,Vector2D &attacker11_pos,Vector2D &attacker22_pos,Vector2D &attacker33_pos,Vector2D &attacker44_pos,Vector2D &attacker55_pos,Vector2D &attacker66_pos,Vector2D &attacker77_pos,Vector2D &attacker88_pos)
+{
+    if(Judge_for_each_situation(me_pos,attacker11_pos))
+        set_stop(attacker11_pos,30,11);
+    else if(Judge_for_each_situation(me_pos,attacker22_pos))
+        set_stop(attacker22_pos,54,10);
+    else if(Judge_for_each_situation(me_pos,attacker33_pos))
+        set_stop(attacker33_pos,10,17);
+    else if(Judge_for_each_situation(me_pos,attacker44_pos))
+        set_stop(attacker44_pos,10,31);
+    else if(Judge_for_each_situation(me_pos,attacker55_pos))
+        set_stop(attacker55_pos,30,38);
+    else if(Judge_for_each_situation(me_pos,attacker66_pos))
+        set_stop(attacker66_pos,54,38);
+    else if(Judge_for_each_situation(me_pos,attacker77_pos))
+        set_stop(attacker77_pos,74,31);
+    else if(Judge_for_each_situation(me_pos,attacker88_pos))
+        set_stop(attacker88_pos,74,17);
+}
 
 
-  void Start::check_body_collisions(Gamepad &pad)
+void Start::check_body_collisions(Gamepad &pad)
 {
-        Vector2D attacker11_pos = _attacker1.get_pos();
-        Vector2D attacker22_pos = _attacker2.get_pos();
-        Vector2D attacker33_pos = _attacker3.get_pos();
-        Vector2D attacker44_pos = _attacker4.get_pos();
-        Vector2D attacker55_pos = _attacker5.get_pos();
-        Vector2D attacker66_pos = _attacker6.get_pos();
-        Vector2D attacker77_pos = _attacker7.get_pos();
-        Vector2D attacker88_pos = _attacker8.get_pos();
-        
-
-        Vector2D me_pos = _me.get_pos();
-    if ((attacker11_pos.x+1 == me_pos.x) &&(attacker11_pos.y+1 == me_pos.y)||
-        (attacker11_pos.x+1 == me_pos.x) &&(attacker11_pos.y   == me_pos.y)||
-        (attacker11_pos.x+1 == me_pos.x) &&(attacker11_pos.y-1 == me_pos.y)||  
-        (attacker11_pos.x+1 == me_pos.x) &&(attacker11_pos.y-2 == me_pos.y)        //if attacker collides me from left
-       )
-      {
-        ifnotstop = false;
-       attacker11_pos.x=30;                                                        //attacker back to initial position
-       attacker11_pos.y=11;                
-      }
-    if ((attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y+1 == me_pos.y)||
-        (attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y   == me_pos.y)||
-        (attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y-1 == me_pos.y)||  
-        (attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y-2 == me_pos.y)        //right
-       )
-      {
-        ifnotstop = false;
-       attacker11_pos.x=30;
-       attacker11_pos.y=11;
-      }
-    if ((attacker11_pos.x == me_pos.x-1) &&(attacker11_pos.y+2 == me_pos.y+1)||
-        (attacker11_pos.x == me_pos.x  ) &&(attacker11_pos.y+2 == me_pos.y+1)||
-        (attacker11_pos.x == me_pos.x+1) &&(attacker11_pos.y+2 == me_pos.y+1)||  
-        (attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y+2 == me_pos.y+1)        //up
-       )
-      {
-        ifnotstop = false;
-       attacker11_pos.x=30;
-       attacker11_pos.y=11;
-      }
-    if ((attacker11_pos.x == me_pos.x-1) &&(attacker11_pos.y == me_pos.y+2)||
-        (attacker11_pos.x == me_pos.x  ) &&(attacker11_pos.y == me_pos.y+2)||
-        (attacker11_pos.x == me_pos.x+1) &&(attacker11_pos.y == me_pos.y+2)||  
-        (attacker11_pos.x == me_pos.x+2) &&(attacker11_pos.y == me_pos.y+2)        //down
-       )
-      {
-        ifnotstop = false;
-       attacker11_pos.x=30;
-       attacker11_pos.y=11;
-      }
- /////////////////////////////////////////////////////////////////////////////////////////////////     
-      
-    if ((attacker22_pos.x+1 == me_pos.x) &&(attacker22_pos.y+1 == me_pos.y)||
-        (attacker22_pos.x+1 == me_pos.x) &&(attacker22_pos.y   == me_pos.y)||
-        (attacker22_pos.x+1 == me_pos.x) &&(attacker22_pos.y-1 == me_pos.y)||  
-        (attacker22_pos.x+1 == me_pos.x) &&(attacker22_pos.y-2 == me_pos.y)        //left
-       )
-      {
-        ifnotstop = false;
-       attacker22_pos.x=54;
-       attacker22_pos.y=10;
-      }
-    if ((attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y+1 == me_pos.y)||
-        (attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y   == me_pos.y)||
-        (attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y-1 == me_pos.y)||  
-        (attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y-2 == me_pos.y)        //right
-       )
-      {
-        ifnotstop = false;
-       attacker22_pos.x=54;
-       attacker22_pos.y=10;
-      }
-    if ((attacker22_pos.x == me_pos.x-1) &&(attacker22_pos.y+2 == me_pos.y+1)||
-        (attacker22_pos.x == me_pos.x  ) &&(attacker22_pos.y+2 == me_pos.y+1)||
-        (attacker22_pos.x == me_pos.x+1) &&(attacker22_pos.y+2 == me_pos.y+1)||  
-        (attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y+2 == me_pos.y+1)        //up
-       )
-      {
-        ifnotstop = false;
-       attacker22_pos.x=54;
-       attacker22_pos.y=10;
-      }
-    if ((attacker22_pos.x == me_pos.x-1) &&(attacker22_pos.y == me_pos.y+2)||
-        (attacker22_pos.x == me_pos.x  ) &&(attacker22_pos.y == me_pos.y+2)||
-        (attacker22_pos.x == me_pos.x+1) &&(attacker22_pos.y == me_pos.y+2)||  
-        (attacker22_pos.x == me_pos.x+2) &&(attacker22_pos.y == me_pos.y+2)        //down
-       )
-      {
-        ifnotstop = false;
-       attacker22_pos.x=54;
-       attacker22_pos.y=10;
-      }
-      /////////////////////////////////////////////////////////////////
-    if ((attacker33_pos.x+1 == me_pos.x) &&(attacker33_pos.y+1 == me_pos.y)||
-        (attacker33_pos.x+1 == me_pos.x) &&(attacker33_pos.y   == me_pos.y)||
-        (attacker33_pos.x+1 == me_pos.x) &&(attacker33_pos.y-1 == me_pos.y)||  
-        (attacker33_pos.x+1 == me_pos.x) &&(attacker33_pos.y-2 == me_pos.y)        //left
-       )
-      {
-        ifnotstop = false;
-       attacker33_pos.x=10;
-       attacker33_pos.y=17;
-      }
-    if ((attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y+1 == me_pos.y)||
-        (attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y   == me_pos.y)||
-        (attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y-1 == me_pos.y)||  
-        (attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y-2 == me_pos.y)        //right
-       )
-      {
-        ifnotstop = false;
-       attacker33_pos.x=10;
-       attacker33_pos.y=17;
-      }
-    if ((attacker33_pos.x == me_pos.x-1) &&(attacker33_pos.y+2 == me_pos.y+1)||
-        (attacker33_pos.x == me_pos.x  ) &&(attacker33_pos.y+2 == me_pos.y+1)||
-        (attacker33_pos.x == me_pos.x+1) &&(attacker33_pos.y+2 == me_pos.y+1)||  
-        (attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y+2 == me_pos.y+1)        //up
-       )
-      {
-        ifnotstop = false;
-       attacker33_pos.x=10;
-       attacker33_pos.y=17;
-      }
-    if ((attacker33_pos.x == me_pos.x-1) &&(attacker33_pos.y == me_pos.y+2)||
-        (attacker33_pos.x == me_pos.x  ) &&(attacker33_pos.y == me_pos.y+2)||
-        (attacker33_pos.x == me_pos.x+1) &&(attacker33_pos.y == me_pos.y+2)||  
-        (attacker33_pos.x == me_pos.x+2) &&(attacker33_pos.y == me_pos.y+2)        //down
-       )
-      {
-        ifnotstop = false;
-       attacker33_pos.x=10;
-       attacker33_pos.y=17;
-      }
- /////////////////////////////////////////////////////////////////////////////////////////////////     
-      
-    if ((attacker44_pos.x+1 == me_pos.x) &&(attacker44_pos.y+1 == me_pos.y)||
-        (attacker44_pos.x+1 == me_pos.x) &&(attacker44_pos.y   == me_pos.y)||
-        (attacker44_pos.x+1 == me_pos.x) &&(attacker44_pos.y-1 == me_pos.y)||  
-        (attacker44_pos.x+1 == me_pos.x) &&(attacker44_pos.y-2 == me_pos.y)        //left
-       )
-      {
-        ifnotstop = false;
-       attacker44_pos.x=10;
-       attacker44_pos.y=31;
-      }
-    if ((attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y+1 == me_pos.y)||
-        (attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y   == me_pos.y)||
-        (attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y-1 == me_pos.y)||  
-        (attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y-2 == me_pos.y)        //right
-       )
-      {
-        ifnotstop = false;
-       attacker44_pos.x=10;
-       attacker44_pos.y=31;
-      }
-    if ((attacker44_pos.x == me_pos.x-1) &&(attacker44_pos.y+2 == me_pos.y+1)||
-        (attacker44_pos.x == me_pos.x  ) &&(attacker44_pos.y+2 == me_pos.y+1)||
-        (attacker44_pos.x == me_pos.x+1) &&(attacker44_pos.y+2 == me_pos.y+1)||  
-        (attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y+2 == me_pos.y+1)        //up
-       )
-      {
-        ifnotstop = false;
-       attacker44_pos.x=10;
-       attacker44_pos.y=31;
-      }
-    if ((attacker44_pos.x == me_pos.x-1) &&(attacker44_pos.y == me_pos.y+2)||
-        (attacker44_pos.x == me_pos.x  ) &&(attacker44_pos.y == me_pos.y+2)||
-        (attacker44_pos.x == me_pos.x+1) &&(attacker44_pos.y == me_pos.y+2)||  
-        (attacker44_pos.x == me_pos.x+2) &&(attacker44_pos.y == me_pos.y+2)        //down
-       )
-      {
-        ifnotstop = false;
-       attacker44_pos.x=10;
-       attacker44_pos.y=31;
-      }
-      ///////////////////////////////////////////////////////////////////
-    if ((attacker55_pos.x+1 == me_pos.x) &&(attacker55_pos.y+1 == me_pos.y)||
-        (attacker55_pos.x+1 == me_pos.x) &&(attacker55_pos.y   == me_pos.y)||
-        (attacker55_pos.x+1 == me_pos.x) &&(attacker55_pos.y-1 == me_pos.y)||  
-        (attacker55_pos.x+1 == me_pos.x) &&(attacker55_pos.y-2 == me_pos.y)        //left
-       )
-      {
-        ifnotstop = false;
-       attacker55_pos.x=30;
-       attacker55_pos.y=38;
-      }
-    if ((attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y+1 == me_pos.y)||
-        (attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y   == me_pos.y)||
-        (attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y-1 == me_pos.y)||  
-        (attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y-2 == me_pos.y)        //right
-       )
-      {
-        ifnotstop = false;
-       attacker11_pos.x=30;
-       attacker11_pos.y=38;
-      }
-    if ((attacker55_pos.x == me_pos.x-1) &&(attacker55_pos.y+2 == me_pos.y+1)||
-        (attacker55_pos.x == me_pos.x  ) &&(attacker55_pos.y+2 == me_pos.y+1)||
-        (attacker55_pos.x == me_pos.x+1) &&(attacker55_pos.y+2 == me_pos.y+1)||  
-        (attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y+2 == me_pos.y+1)        //up
-       )
-      {
-        ifnotstop = false;
-       attacker55_pos.x=30;
-       attacker55_pos.y=38;
-      }
-    if ((attacker55_pos.x == me_pos.x-1) &&(attacker55_pos.y == me_pos.y+2)||
-        (attacker55_pos.x == me_pos.x  ) &&(attacker55_pos.y == me_pos.y+2)||
-        (attacker55_pos.x == me_pos.x+1) &&(attacker55_pos.y == me_pos.y+2)||  
-        (attacker55_pos.x == me_pos.x+2) &&(attacker55_pos.y == me_pos.y+2)        //down
-       )
-      {
-        ifnotstop = false;
-       attacker55_pos.x=30;
-       attacker55_pos.y=38;
-      }
- /////////////////////////////////////////////////////////////////////////////////////////////////     
-      
-    if ((attacker66_pos.x+1 == me_pos.x) &&(attacker66_pos.y+1 == me_pos.y)||
-        (attacker66_pos.x+1 == me_pos.x) &&(attacker66_pos.y   == me_pos.y)||
-        (attacker66_pos.x+1 == me_pos.x) &&(attacker66_pos.y-1 == me_pos.y)||  
-        (attacker66_pos.x+1 == me_pos.x) &&(attacker66_pos.y-2 == me_pos.y)        //left
-       )
-      {
-        ifnotstop = false;
-       attacker66_pos.x=54;
-       attacker66_pos.y=38;
-      }
-    if ((attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y+1 == me_pos.y)||
-        (attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y   == me_pos.y)||
-        (attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y-1 == me_pos.y)||  
-        (attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y-2 == me_pos.y)        //right
-       )
-      {
-        ifnotstop = false;
-       attacker66_pos.x=54;
-       attacker66_pos.y=38;
-      }
-    if ((attacker66_pos.x == me_pos.x-1) &&(attacker66_pos.y+2 == me_pos.y+1)||
-        (attacker66_pos.x == me_pos.x  ) &&(attacker66_pos.y+2 == me_pos.y+1)||
-        (attacker66_pos.x == me_pos.x+1) &&(attacker66_pos.y+2 == me_pos.y+1)||  
-        (attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y+2 == me_pos.y+1)        //up
-       )
-      {
-        ifnotstop = false;
-       attacker66_pos.x=54;
-       attacker66_pos.y=38;
-      }
-    if ((attacker66_pos.x == me_pos.x-1) &&(attacker66_pos.y == me_pos.y+2)||
-        (attacker66_pos.x == me_pos.x  ) &&(attacker66_pos.y == me_pos.y+2)||
-        (attacker66_pos.x == me_pos.x+1) &&(attacker66_pos.y == me_pos.y+2)||  
-        (attacker66_pos.x == me_pos.x+2) &&(attacker66_pos.y == me_pos.y+2)        //down
-       )
-      {
-        ifnotstop = false;
-       attacker66_pos.x=54;
-       attacker66_pos.y=38;
-      }
-      ///////////////////////////////////////////////////////
-    if ((attacker77_pos.x+1 == me_pos.x) &&(attacker77_pos.y+1 == me_pos.y)||
-        (attacker77_pos.x+1 == me_pos.x) &&(attacker77_pos.y   == me_pos.y)||
-        (attacker77_pos.x+1 == me_pos.x) &&(attacker77_pos.y-1 == me_pos.y)||  
-        (attacker77_pos.x+1 == me_pos.x) &&(attacker77_pos.y-2 == me_pos.y)        //left
-       )
-      {
-        ifnotstop = false;
-       attacker77_pos.x=74;
-       attacker77_pos.y=31;
-      }
-    if ((attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y+1 == me_pos.y)||
-        (attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y   == me_pos.y)||
-        (attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y-1 == me_pos.y)||  
-        (attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y-2 == me_pos.y)        //right
-       )
-      {
-        ifnotstop = false;
-       attacker77_pos.x=74;
-       attacker77_pos.y=31;
-      }
-    if ((attacker77_pos.x == me_pos.x-1) &&(attacker77_pos.y+2 == me_pos.y+1)||
-        (attacker77_pos.x == me_pos.x  ) &&(attacker77_pos.y+2 == me_pos.y+1)||
-        (attacker77_pos.x == me_pos.x+1) &&(attacker77_pos.y+2 == me_pos.y+1)||  
-        (attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y+2 == me_pos.y+1)        //up
-       )
-      {
-        ifnotstop = false;
-       attacker77_pos.x=74;
-       attacker77_pos.y=31;
-      }
-    if ((attacker77_pos.x == me_pos.x-1) &&(attacker77_pos.y == me_pos.y+2)||
-        (attacker77_pos.x == me_pos.x  ) &&(attacker77_pos.y == me_pos.y+2)||
-        (attacker77_pos.x == me_pos.x+1) &&(attacker77_pos.y == me_pos.y+2)||  
-        (attacker77_pos.x == me_pos.x+2) &&(attacker77_pos.y == me_pos.y+2)        //down
-       )
-      {
-       ifnotstop = false;
-       attacker77_pos.x=74;
-       attacker77_pos.y=31;
-      }
- /////////////////////////////////////////////////////////////////////////////////////////////////     
-      
-    if ((attacker88_pos.x+1 == me_pos.x) &&(attacker88_pos.y+1 == me_pos.y)||
-        (attacker88_pos.x+1 == me_pos.x) &&(attacker88_pos.y   == me_pos.y)||
-        (attacker88_pos.x+1 == me_pos.x) &&(attacker88_pos.y-1 == me_pos.y)||  
-        (attacker88_pos.x+1 == me_pos.x) &&(attacker88_pos.y-2 == me_pos.y)        //left
-       )
-      {
-        ifnotstop = false;
-       attacker88_pos.x=74;
-       attacker88_pos.y=17;
-      }
-    if ((attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y+1 == me_pos.y)||
-        (attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y   == me_pos.y)||
-        (attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y-1 == me_pos.y)||  
-        (attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y-2 == me_pos.y)        //right
-       )
-      {
-        ifnotstop = false;
-       attacker88_pos.x=74;
-       attacker88_pos.y=17;
-      }
-    if ((attacker88_pos.x == me_pos.x-1) &&(attacker88_pos.y+2 == me_pos.y+1)||
-        (attacker88_pos.x == me_pos.x  ) &&(attacker88_pos.y+2 == me_pos.y+1)||
-        (attacker88_pos.x == me_pos.x+1) &&(attacker88_pos.y+2 == me_pos.y+1)||  
-        (attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y+2 == me_pos.y+1)        //up
-       )
-      {
-        ifnotstop = false;
-       attacker88_pos.x=74;
-       attacker88_pos.y=17;
-      }
-    if ((attacker88_pos.x == me_pos.x-1) &&(attacker88_pos.y == me_pos.y+2)||
-        (attacker88_pos.x == me_pos.x  ) &&(attacker88_pos.y == me_pos.y+2)||
-        (attacker88_pos.x == me_pos.x+1) &&(attacker88_pos.y == me_pos.y+2)||  
-        (attacker88_pos.x == me_pos.x+2) &&(attacker88_pos.y == me_pos.y+2)        //down
-       )
-      {
-        ifnotstop = false;
-       attacker88_pos.x=74;
-       attacker88_pos.y=17;
-      }
-      
+    Vector2D attacker11_pos = _attacker1.get_pos();
+    Vector2D attacker22_pos = _attacker2.get_pos();
+    Vector2D attacker33_pos = _attacker3.get_pos();
+    Vector2D attacker44_pos = _attacker4.get_pos();
+    Vector2D attacker55_pos = _attacker5.get_pos();
+    Vector2D attacker66_pos = _attacker6.get_pos();
+    Vector2D attacker77_pos = _attacker7.get_pos();
+    Vector2D attacker88_pos = _attacker8.get_pos();
+    Vector2D me_pos = _me.get_pos();
+    Judge_ifstop(me_pos,attacker11_pos,attacker22_pos,attacker33_pos,attacker44_pos,attacker55_pos,attacker66_pos,attacker77_pos,attacker88_pos);
     _attacker1.set_pos(attacker11_pos);
     _attacker2.set_pos(attacker22_pos);
     _attacker3.set_pos(attacker33_pos);
@@ -485,6 +198,5 @@
     _attacker5.set_pos(attacker55_pos);
     _attacker6.set_pos(attacker66_pos);
     _attacker7.set_pos(attacker77_pos);
-    _attacker8.set_pos(attacker88_pos);
-    
+    _attacker8.set_pos(attacker88_pos);    
 }