Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. void keyPressed()
  2. {
  3. if(key == 'w')
  4. {
  5. if (down == true)
  6. {
  7. down = false;
  8. }
  9. up = true;
  10. }
  11.  
  12. if(key == 'a')
  13. {
  14. if (right == true)
  15. {
  16. right = false;
  17. }
  18. left = true;
  19. }
  20.  
  21. if(key == 'd')
  22. {
  23. if (left == true)
  24. {
  25. left = false;
  26. }
  27. right = true;
  28. }
  29.  
  30. if(key == 's')
  31. {
  32. if (up == true)
  33. {
  34. up = false;
  35. }
  36. down = true;
  37. }
  38.  
  39. if(key == ' ')
  40. {
  41. player.activatePulse();
  42. }
  43. }
  44.  
  45. void keyReleased()
  46. {
  47. if(key == 'w')
  48. {
  49. up = false;
  50. }
  51.  
  52. if(key == 'a')
  53. {
  54. left = false;
  55. }
  56.  
  57. if(key == 'd')
  58. {
  59. right = false;
  60. }
  61.  
  62. if(key == 's')
  63. {
  64. down = false;
  65. }
  66. }
  67.  
  68.  
  69. void movePlayer()
  70. {
  71. if(down == true && right == true)
  72. {
  73. player.xPosition += 3;
  74. player.yPosition += 3;
  75. }
  76. else if(down == true && left == true)
  77. {
  78. player.xPosition -= 3;
  79. player.yPosition += 3;
  80. }
  81. else if(up == true && right == true)
  82. {
  83. player.xPosition += 3;
  84. player.yPosition -= 3;
  85. }
  86. else if(up == true && left == true)
  87. {
  88. player.xPosition -= 3;
  89. player.yPosition -= 3;
  90. }
  91. else if(up == true)
  92. {
  93. player.yPosition -= 3;
  94. }
  95. else if(down == true)
  96. {
  97. player.yPosition += 3;
  98. }
  99. else if(right == true)
  100. {
  101. player.xPosition += 3;
  102. }
  103. else if(left == true)
  104. {
  105. player.xPosition -= 3;
  106. }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement