Advertisement
DwarvenEmpires

Dwarven Empires Movement code

Dec 16th, 2011
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. //Code Copywrite 2011 Ethan Gomez Gaming Studios (EGGS for short) This code may NOT be used under any circumstance without the written and exclusive permission of EGGS.
  2. public class wMotion implements ActionListener {
  3. public void actionPerformed(ActionEvent e) {
  4. DwarvenEmpires.y.setValue(DwarvenEmpires.y.getValue() - moveDist);
  5. }
  6. }
  7.  
  8. public class sMotion implements ActionListener {
  9. public void actionPerformed(ActionEvent e) {
  10. DwarvenEmpires.y.setValue(DwarvenEmpires.y.getValue() + moveDist);
  11. }
  12. }
  13.  
  14. public class dMotion implements ActionListener {
  15. public void actionPerformed(ActionEvent e) {
  16. DwarvenEmpires.x.setValue(DwarvenEmpires.x.getValue() + moveDist);
  17. }
  18. }
  19.  
  20. public class aMotion implements ActionListener {
  21. public void actionPerformed(ActionEvent e) {
  22. DwarvenEmpires.x.setValue(DwarvenEmpires.x.getValue() - moveDist);
  23. }
  24. }
  25.  
  26. public static class frameChangeTimer implements ActionListener {
  27.  
  28. public void actionPerformed(ActionEvent e) {
  29. imageValue1 += 1;
  30. imageValue2 += 1;
  31. if (imageValue2 >= 4) {
  32. imageValue2 = 0;
  33. }
  34. if (imageValue1 >= 4) {
  35. imageValue1 = 0;
  36. }
  37. }
  38. }
  39.  
  40.  
  41. //In another method...
  42. if (ip.isKeyPressed(Input.KEY_W)) {
  43.  
  44. DwarvenEmpires.c.setChar(wMotion[imageValue1]);
  45. imageMotion.start();
  46. wMotionTimer.start();
  47.  
  48. }
  49.  
  50. if (!ip.isKeyDown(Input.KEY_W)) {
  51.  
  52. aMotionTimer.stop();
  53. dMotionTimer.stop();
  54. sMotionTimer.stop();
  55. wMotionTimer.stop();
  56.  
  57. }
  58. }
  59.  
  60.  
  61. if (ip.isKeyPressed(Input.KEY_S)) {
  62.  
  63.  
  64.  
  65. imageMotion.start();
  66. sMotionTimer.start();
  67. DwarvenEmpires.c.setChar(sMotion[imageValue1]);
  68.  
  69. }
  70.  
  71. if (ip.isKeyDown(Input.KEY_S)) {
  72. wMotionTimer.stop();
  73. aMotionTimer.stop();
  74. dMotionTimer.stop();
  75. sMotionTimer.stop();
  76.  
  77.  
  78. }
  79.  
  80.  
  81.  
  82. if (ip.isKeyPressed(Input.KEY_D)) {
  83.  
  84. imageMotion.start();
  85. dMotionTimer.start();
  86. DwarvenEmpires.c.setChar(dMotion[imageValue2]);
  87.  
  88.  
  89. }
  90.  
  91. if (!ip.isKeyDown(Input.KEY_D)) {
  92.  
  93. wMotionTimer.stop();
  94. aMotionTimer.stop();
  95. sMotionTimer.stop();
  96. dMotionTimer.stop();
  97.  
  98. }
  99.  
  100. if (ip.isKeyPressed(Input.KEY_A)) {
  101. imageMotion.start();
  102. aMotionTimer.start();
  103. DwarvenEmpires.c.setChar(aMotion[imageValue2]);
  104.  
  105. }
  106.  
  107.  
  108. if (!ip.isKeyDown(Input.KEY_A)) {
  109. dMotionTimer.stop();
  110. wMotionTimer.stop();
  111. sMotionTimer.stop();
  112. aMotionTimer.stop();
  113.  
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement