コード例 #1
0
ファイル: myServe.cs プロジェクト: coreyschulz/space-wars
 public void checkIfOffScreen(projectile pro, bool extra)
 {
     if (extra == false) // If Touhou is off, make the projectiles kill when they get offscreen.
     {
         if (pro.GetLocation().GetX() > universeSize / 2 + 50 || pro.GetLocation().GetX() < -universeSize / 2 - 50)
         {
             pro.kill();
         }
         if (pro.GetLocation().GetY() > universeSize / 2 + 50 || pro.GetLocation().GetY() < -universeSize / 2 - 50)
         {
             pro.kill();
         }
     }
     else
     {
         if (pro.GetLocation().GetX() > universeSize / 2 || pro.GetLocation().GetX() < -universeSize / 2)
         {
             //we will want it to keep the y position and just rotate to the other side of the screen.
             double   yLocation    = pro.GetLocation().GetY();
             double   oldxLocation = pro.GetLocation().GetX();
             Vector2D newLocation  = new Vector2D(-(oldxLocation), yLocation);
             //Set the projectile location to the new location
             pro.setLocation(newLocation);
         }
         if (pro.GetLocation().GetY() > universeSize / 2 || pro.GetLocation().GetY() < -universeSize / 2)
         {
             //we will want it to keep the y position and just rotate to the other side of the screen.
             double   yLocation   = pro.GetLocation().GetY();
             double   xLocation   = pro.GetLocation().GetX();
             Vector2D newLocation = new Vector2D(xLocation, -yLocation);
             pro.setLocation(newLocation); // Set projectile to modified location.
         }
     }
 }