Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. public void Update (GamePadData gamePadData, long deltaT)
  2. {
  3. frameTime += deltaT;
  4. if (frameTime > FRAME_DURATION) {
  5. frameTime = 0;
  6.  
  7. if (pid == 1) {
  8. if ((gamePadData.Buttons & GamePadButtons.Left) != 0)
  9. {
  10. pos.X -= vel;
  11. currentDir = Direction.Left;
  12. activeFrame += 1;
  13. }
  14. if ((gamePadData.Buttons & GamePadButtons.Right) != 0)
  15. {
  16. pos.X += vel;
  17. currentDir = Direction.Right;
  18. activeFrame += 1;
  19. }
  20. if ((gamePadData.Buttons & GamePadButtons.Up) != 0)
  21. {
  22. pos.Y -= vel;
  23. currentDir = Direction.Up;
  24. activeFrame += 1;
  25. }
  26. if ((gamePadData.Buttons & GamePadButtons.Down) != 0)
  27. {
  28. pos.Y += vel;
  29. currentDir = Direction.Down;
  30. activeFrame += 1;
  31. }
  32.  
  33. }
  34. if (pid == 2) {
  35. if ((gamePadData.Buttons & GamePadButtons.Square) != 0)
  36. {
  37. pos.X -= vel;
  38. currentDir = Direction.Left;
  39. activeFrame += 1;
  40. }
  41. if ((gamePadData.Buttons & GamePadButtons.Circle) != 0)
  42. {
  43. pos.X += vel;
  44. currentDir = Direction.Right;
  45. activeFrame += 1;
  46. }
  47. if ((gamePadData.Buttons & GamePadButtons.Triangle) != 0)
  48. {
  49. pos.Y -= vel;
  50. currentDir = Direction.Up;
  51. activeFrame += 1;
  52. }
  53. if ((gamePadData.Buttons & GamePadButtons.Cross) != 0)
  54. {
  55. pos.Y += vel;
  56. currentDir = Direction.Down;
  57. activeFrame += 1;
  58. }
  59. }
  60.  
  61. if (activeFrame > 3)
  62. activeFrame = 0;
  63.  
  64. sprite.Position = pos;
  65.  
  66. //Keeping the sprite on screen
  67. Lock ();
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement