Guest User

Untitled

a guest
Aug 21st, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.78 KB | None | 0 0
  1.                 gamePadState.IsButtonDown(Buttons.LeftThumbstickLeft) ||
  2.                 gamePadState.IsButtonDown(Buttons.DPadLeft))
  3.                 motion.X = -1;
  4.             if (keyboardState.IsKeyDown(Keys.Right) ||
  5.                             gamePadState.IsButtonDown(Buttons.LeftThumbstickRight) ||
  6.                             gamePadState.IsButtonDown(Buttons.DPadRight))
  7.                 motion.X = 1;
  8.             motion.X *= paddleSpeed;
  9.             position += motion;
  10.             paddleSpeed += 0.01f;
  11.             LockPaddle();
  12.  
  13.             if (GamePad.GetState(PlayerIndex.One).Buttons.LeftShoulder == ButtonState.Pressed
  14.                 && GamePad.GetState(PlayerIndex.One).DPad.Down == ButtonState.Pressed)
  15.             {
  16.                 homingMode = true;
  17.             }
  18.  
  19.             if (homingMode == true)
  20.             {
  21.                 this.position.X = ball;
  22.             }
  23.  
  24.  
  25.         }
  26.         private void LockPaddle()
  27.         {
  28.             if (position.X < 0)
  29.                 position.X = 0;
  30.             if (position.X + texture.Width > screenBounds.Width)
  31.                 position.X = screenBounds.Width - texture.Width;
  32.         }
  33.         public void SetInStartPosition()
  34.         {
  35.             paddleSpeed = paddleStartSpeed;
  36.             position.X = (screenBounds.Width - texture.Width) / 2;
  37.             position.Y = screenBounds.Height - texture.Height - 5;
  38.         }
  39.  
  40.  
  41.  
  42.         public void Draw(SpriteBatch spriteBatch)
  43.         {
  44.             spriteBatch.Draw(texture, position, Color.White);
  45.         }
  46.  
  47.         public Rectangle GetBounds()
  48.         {
  49.             return new Rectangle(
  50.             (int)position.X,
  51.             (int)position.Y,
  52.             texture.Width,
  53.             texture.Height);
  54.         }
  55.  
  56.         public float ball { get; set; }
Add Comment
Please, Sign In to add comment