Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- gamePadState.IsButtonDown(Buttons.LeftThumbstickLeft) ||
- gamePadState.IsButtonDown(Buttons.DPadLeft))
- motion.X = -1;
- if (keyboardState.IsKeyDown(Keys.Right) ||
- gamePadState.IsButtonDown(Buttons.LeftThumbstickRight) ||
- gamePadState.IsButtonDown(Buttons.DPadRight))
- motion.X = 1;
- motion.X *= paddleSpeed;
- position += motion;
- paddleSpeed += 0.01f;
- LockPaddle();
- if (GamePad.GetState(PlayerIndex.One).Buttons.LeftShoulder == ButtonState.Pressed
- && GamePad.GetState(PlayerIndex.One).DPad.Down == ButtonState.Pressed)
- {
- homingMode = true;
- }
- if (homingMode == true)
- {
- this.position.X = ball;
- }
- }
- private void LockPaddle()
- {
- if (position.X < 0)
- position.X = 0;
- if (position.X + texture.Width > screenBounds.Width)
- position.X = screenBounds.Width - texture.Width;
- }
- public void SetInStartPosition()
- {
- paddleSpeed = paddleStartSpeed;
- position.X = (screenBounds.Width - texture.Width) / 2;
- position.Y = screenBounds.Height - texture.Height - 5;
- }
- public void Draw(SpriteBatch spriteBatch)
- {
- spriteBatch.Draw(texture, position, Color.White);
- }
- public Rectangle GetBounds()
- {
- return new Rectangle(
- (int)position.X,
- (int)position.Y,
- texture.Width,
- texture.Height);
- }
- public float ball { get; set; }
Add Comment
Please, Sign In to add comment