示例#1
0
        public void Update(KeyboardState kstate, GameTime gameTime, Ball ball)
        {
            if (kstate.IsKeyDown(Keys.Left))
            {
                Move(-SpeedPaddle * (float)gameTime.ElapsedGameTime.TotalSeconds, 0);
            }

            if (kstate.IsKeyDown(Keys.Right))
            {
                Move(SpeedPaddle * (float)gameTime.ElapsedGameTime.TotalSeconds, 0);
            }
            MoveTo(Math.Min(Math.Max(game.X0, GetPosition().X), game.X0 + game.Width - Width));
            if (!ball.Launc)
            {
                ball.MoveTo(GetPosition().X + Width / 2 - ball.Width / 2, GetPosition().Y - ball.Height);
            }
        }