示例#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);
            }
        }
示例#2
0
        public override void HandleInput(InputHelper inputHelper)
        {
            if (inputHelper.KeyPressed(Keys.R))
            {
                Color = Color.Red;
            }
            else if (inputHelper.KeyPressed(Keys.G))
            {
                Color = Color.Green;
            }
            else if (inputHelper.KeyPressed(Keys.B))
            {
                Color = Color.Blue;
            }

            double opposite = inputHelper.MousePosition.Y - position.Y;
            double adjacent = inputHelper.MousePosition.X - position.X;

            angle = (float)Math.Atan2(opposite, adjacent);
        }