Beispiel #1
0
        //Bullet collision
        public bool Collision(Character c, Shooting shot)
        {
            // determine the distance between two character objects based on their centres
            double distance = Math.Sqrt(Math.Pow(shot.x - c.x, 2) + (Math.Pow(shot.y - c.y, 2)));

            if (distance < 50)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Takes the towers designated direction and moves it accordingly
 /// </summary>
 /// <param name="shot">Object</param>
 /// <param name="d">Direction of the shot</param>
 /// <param name="f">Form1</param>
 public void Shoot(Shooting shot, int d, Form f)
 {
     // move shot down
     if (direction == 3)
     {
         shot.y = shot.y - shot.speed;
     }
     //move shot up
     else if (direction == 0)
     {
         shot.y = shot.y + shot.speed;
     }
     //move shot left
     else if (direction == 1)
     {
         shot.x = shot.x - shot.speed;
     }
     //move shot right
     else if (direction == 2)
     {
         shot.x = shot.x + shot.speed;
     }
     //move shot up and left
     else if (direction == 4)
     {
         shot.x = shot.x - shot.speed;
         shot.y = shot.y - shot.speed;
     }
     //move shot up and right
     else if (direction == 5)
     {
         shot.x = shot.x + shot.speed;
         shot.y = shot.y - shot.speed;
     }
     //move shot down and left
     else if (direction == 6)
     {
         shot.x = shot.x - shot.speed;
         shot.y = shot.y + shot.speed;
     }
     //move shot down and right
     else if (direction == 7)
     {
         shot.x = shot.x + shot.speed;
         shot.y = shot.y + shot.speed;
     }
 }