publish my project

Dependencies:   mbed

Revision:
3:c89450845b2a
Parent:
0:9e95a5ef2659
Child:
4:fd47d9c11263
--- a/Start/Start.cpp	Mon Apr 27 07:01:39 2020 +0000
+++ b/Start/Start.cpp	Mon Apr 27 11:59:39 2020 +0000
@@ -82,6 +82,31 @@
     check_body_collisions(pad);
 
 }
+void setpos(Vector2D attacker_pos,int x,int 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)
+{
+    if(attacker11_pos.y < 10||attacker11_pos.y > 36||attacker11_pos.x > 72) 
+        setpos(attacker11_pos,30,11);  
+    else if(attacker22_pos.y < 10||attacker22_pos.y > 36||attacker22_pos.x < 10||attacker22_pos.x > 72)
+        setpos(attacker22_pos,54,10); 
+    else if(attacker33_pos.y < 10||attacker33_pos.y > 36||attacker33_pos.x < 10||attacker33_pos.x > 72)
+        setpos(attacker33_pos,10,17); 
+    else if(attacker44_pos.y < 10||attacker44_pos.y > 36||attacker11_pos.x < 10||attacker44_pos.x > 72)
+        setpos(attacker44_pos,10,31);  
+    else if(attacker55_pos.y < 10||attacker55_pos.y > 36||attacker55_pos.x < 10||attacker55_pos.x > 72)
+        setpos(attacker55_pos,30,36); 
+    else if(attacker66_pos.y < 10||attacker66_pos.y > 36||attacker66_pos.x < 10||attacker66_pos.x >72)
+        setpos(attacker66_pos,54,36);
+    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);
+}
 
 void Start::check_wall_collision(Gamepad &pad)
 {
@@ -93,176 +118,9 @@
     Vector2D attacker66_pos = _attacker6.get_pos();
     Vector2D attacker77_pos = _attacker7.get_pos();
     Vector2D attacker88_pos = _attacker8.get_pos();
-    
 
-    if(attacker11_pos.y < 10)     //if collision,
-     {  
-       attacker11_pos.x=30;        // position restore.
-       attacker11_pos.y=11;        //every attacker ,totally  8 times.
-     }
-    else if(attacker11_pos.y > 36)
-    {  
-       attacker11_pos.x=30;
-       attacker11_pos.y=11;
-    }
-    else if(attacker11_pos.x < 10)
-    {
-       attacker11_pos.x=30;
-       attacker11_pos.y=11;
-    }
-    else if(attacker11_pos.x > 72)
-    {
-       attacker11_pos.x=30;
-       attacker11_pos.y=11;
-    }
-    
-    if(attacker22_pos.y < 10)
-     {  
-       attacker22_pos.x=54;
-       attacker22_pos.y=10;
-     }
-    else if(attacker22_pos.y > 36)
-    {  
-       attacker22_pos.x=54;
-       attacker22_pos.y=10;
-    }
-    else if(attacker22_pos.x < 10)
-    {
-       attacker22_pos.x=54;
-       attacker22_pos.y=10;
-    }
-    else if(attacker22_pos.x > 72)
-    {
-       attacker22_pos.x=54;
-       attacker22_pos.y=10;
-    }
-    
-    if(attacker33_pos.y < 10)
-     {  
-       attacker33_pos.x=10;
-       attacker33_pos.y=17;
-     }
-    else if(attacker33_pos.y > 36)
-    {  
-       attacker33_pos.x=10;
-       attacker33_pos.y=17;
-    }
-    else if(attacker33_pos.x < 10)
-    {
-       attacker33_pos.x=10;
-       attacker33_pos.y=17;
-    }
-    else if(attacker33_pos.x > 72)
-    {
-       attacker33_pos.x=10;
-       attacker33_pos.y=17;
-    }
-    
-    if(attacker44_pos.y < 10)
-     {  
-       attacker44_pos.x=10;
-       attacker44_pos.y=31;
-     }
-    else if(attacker44_pos.y > 36)
-    {  
-       attacker44_pos.x=10;
-       attacker44_pos.y=31;
-    }
-    else if(attacker11_pos.x < 10)
-    {
-       attacker44_pos.x=10;
-       attacker44_pos.y=31;
-    }
-    else if(attacker44_pos.x > 72)
-    {
-       attacker44_pos.x=10;
-       attacker44_pos.y=31;
-    }
-    
-    if(attacker55_pos.y < 10)
-     {  
-       attacker55_pos.x=30;
-       attacker55_pos.y=36;
-     }
-    else if(attacker55_pos.y > 36)
-    {  
-       attacker55_pos.x=30;
-       attacker55_pos.y=36;
-    }
-    else if(attacker55_pos.x < 10)
-    {
-       attacker55_pos.x=30;
-       attacker55_pos.y=36;
-    }
-    else if(attacker55_pos.x > 72)
-    {
-       attacker55_pos.x=30;
-       attacker55_pos.y=36;
-    }
-    
-    if(attacker66_pos.y < 10)
-     {  
-       attacker66_pos.x=54;
-       attacker66_pos.y=36;
-     }
-    else if(attacker66_pos.y > 36)
-    {  
-       attacker66_pos.x=54;
-       attacker66_pos.y=36;
-    }
-    else if(attacker66_pos.x < 10)
-    {
-       attacker66_pos.x=54;
-       attacker66_pos.y=36;
-    }
-    else if(attacker66_pos.x > 72)
-    {
-       attacker66_pos.x=54;
-       attacker66_pos.y=36;
-    }
-    
-    if(attacker77_pos.y < 10)
-     {  
-       attacker77_pos.x=71;
-       attacker77_pos.y=31;
-     }
-    else if(attacker77_pos.y > 36)
-    {  
-       attacker77_pos.x=71;
-       attacker77_pos.y=31;
-    }
-    else if(attacker77_pos.x < 10)
-    {
-       attacker77_pos.x=71;
-       attacker77_pos.y=31;
-    }
-    else if(attacker77_pos.x > 72)
-    {
-       attacker77_pos.x=71;
-       attacker77_pos.y=31;
-    }
-    
-    if(attacker88_pos.y < 10)
-     {  
-       attacker88_pos.x=71;
-       attacker88_pos.y=17;
-     }
-    else if(attacker88_pos.y > 36)
-    {  
-       attacker88_pos.x=71;
-       attacker88_pos.y=17;
-    }
-    else if(attacker88_pos.x < 10)
-    {
-       attacker88_pos.x=71;
-       attacker88_pos.y=17;
-    }
-    else if(attacker88_pos.x > 72)
-    {
-       attacker88_pos.x=71;
-       attacker88_pos.y=17;
-    }
-    
+    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);