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); }
public void AttachTo(Paddle paddle) { attachedToPaddle = paddle; }