Advertisement
Guest User

Untitled

a guest
Dec 13th, 2011
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. protected void UpdateInput()
  2. {
  3. // Get the game pad state.
  4. GamePadState currentState = GamePad.GetState(PlayerIndex.One);
  5. if (currentState.IsConnected)
  6. {
  7. // Rotate the model using the left thumbstick, and scale it down
  8. modelRotation -= currentState.ThumbSticks.Left.X * 0.10f;
  9.  
  10. // Create some velocity if the right trigger is down.
  11. Vector3 modelVelocityAdd = Vector3.Zero;
  12.  
  13. // Find out what direction we should be thrusting,
  14. // using rotation.
  15. modelVelocityAdd.X = -(float)Math.Sin(modelRotation);
  16. modelVelocityAdd.Z = -(float)Math.Cos(modelRotation);
  17.  
  18. // Now scale our direction by how hard the trigger is down.
  19. modelVelocityAdd *= currentState.Triggers.Right;
  20.  
  21. // Finally, add this vector to our velocity.
  22. modelVelocity += modelVelocityAdd;
  23.  
  24. GamePad.SetVibration(PlayerIndex.One,
  25. currentState.Triggers.Right,
  26. currentState.Triggers.Right);
  27.  
  28.  
  29. // In case you get lost, press A to warp back to the center.
  30. if (currentState.Buttons.A == ButtonState.Pressed)
  31. {
  32. modelPosition = Vector3.Zero;
  33. modelVelocity = Vector3.Zero;
  34. modelRotation = 0.0f;
  35. }
  36. }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement