Пример #1
0
        public override void Update(GameTime gameTime, GameObjects gameObjects)
        {
            if(Keyboard.GetState().IsKeyDown(Keys.Space) && attachedToPaddle != null)
            {
                var newVelocity = new Vector2(5.0f, attachedToPaddle.Velocity.Y * 0.65f);
                Velocity = newVelocity;
                attachedToPaddle = null;
            }

            if(attachedToPaddle != null)
            {
                Location.X = attachedToPaddle.Location.X + attachedToPaddle.Width;
                Location.Y = attachedToPaddle.Location.Y;
            }
            else
            {
                if (BoundingBox.Intersects(gameObjects.PlayerPaddle.BoundingBox) ||
                    BoundingBox.Intersects(gameObjects.ComputerPaddle.BoundingBox))
                {
                    Velocity = new Vector2(-Velocity.X, Velocity.Y);
                }

            }

            base.Update(gameTime, gameObjects);
        }
Пример #2
0
 public void AttachTo(Paddle paddle)
 {
     attachedToPaddle = paddle;
 }
Пример #3
0
 public void AttachTo(Paddle paddle)
 {
     attachedToPaddle = paddle;
 }