public void LeftThumbStickMove(GamePadState gamePad)
{
position.X += gamePad.ThumbSticks.Left.X * speed;
position.Y -= gamePad.ThumbSticks.Left.Y * speed;
}
public void RightThumbStickMove(GamePadState gamePad)
{
position.X += gamePad.ThumbSticks.Right.X * speed;
position.Y -= gamePad.ThumbSticks.Right.Y * speed;
}
public void DPadMove(GamePadState gamePad)
{
if (gamePad.DPad.Right == ButtonState.Pressed)
{
position.X += speed;
}
if (gamePad.DPad.Left == ButtonState.Pressed)
{
position.X -= speed;
}
if (gamePad.DPad.Up == ButtonState.Pressed)
{
position.Y -= speed;
}
if (gamePad.DPad.Down == ButtonState.Pressed)
{
position.Y += speed;
}
}
// Bounds checking
sprite.position.X = MathHelper.Clamp(sprite.position.X, 0, GraphicsDevice.Viewport.Width - sprite.width);
sprite.position.Y = MathHelper.Clamp(sprite.position.Y, 0, GraphicsDevice.Viewport.Height - sprite.height);
// Draw text to screen
spriteBatch.DrawString(font, "Some text here", new Vector2(20, 45), Color.White);