Esempio n. 1
0
        public override void HandleInput(InputHelper inputHelper)
        {
            base.HandleInput(inputHelper);

            if (inputHelper.KeyPressed(Keys.R))
            {
                cannon.CannonColor.Color = Color.Red;
            }
            else if (inputHelper.KeyPressed(Keys.G))
            {
                cannon.CannonColor.Color = Color.Green;
            }
            else if (inputHelper.KeyPressed(Keys.B))
            {
                cannon.CannonColor.Color = Color.Blue;
            }

            double opposite = inputHelper.MousePosition.Y - cannon.Cannon_barrel.GlobalPosition.Y;
            double adjacent = inputHelper.MousePosition.X - cannon.Cannon_barrel.GlobalPosition.X;

            cannon.Cannon_barrel.Angle = (float)Math.Atan2(opposite, adjacent);

            if (inputHelper.MouseLeftButtonPressed() && !this.ball.Shooting)
            {
                ball.Shoot(inputHelper, cannon.CannonColor, cannon.Cannon_barrel);
            }
        }
Esempio n. 2
0
 public override void HandleInput(InputHelper inputHelper)
 {
     if (inputHelper.MouseLeftButtonPressed() && !shooting)
     {
         shooting = true;
         velocity = (inputHelper.MousePosition - position) * 1.2f;
         ballShot.Play();
         Color = Painter.GameWorld.Cannon.Color;
     }
 }
Esempio n. 3
0
 public override void HandleInput(InputHelper inputHelper)
 {
     if(inputHelper.MouseLeftButtonPressed() && !shooting)
     {
         shooting = true;
         velocity = (inputHelper.MousePosition - position) * speed;
         ballShot.Play();
         Color = Painter.GameWorld.Cannon.Color;
     }
 }