Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. //walking
  2. if status = "idle"
  3. {
  4. speed = 0
  5. itran = 1
  6. //get keyboard input
  7. var hor_input = (ctrl.hRight[1] - ctrl.hLeft[1]);
  8. var ver_input = (ctrl.hDown[1] - ctrl.hUp[1]);
  9.  
  10. if (hor_input != 0 || ver_input != 0)
  11. {
  12. walking = 1
  13. //get direction for movement
  14. var moveDir = point_direction(0, 0, hor_input, ver_input);
  15.  
  16. //movement
  17. var checkX = lengthdir_x(spd, moveDir);
  18. var checkY = lengthdir_y(spd, moveDir);
  19.  
  20. //set sprite
  21. if ver_input = 1
  22. {
  23. pimagexscale = 1
  24. usprite_index = spr_bodyfront
  25. lsprite_index = spr_legsfront
  26. faced = 270
  27. }
  28. if ver_input = -1
  29. {
  30. pimagexscale = 1
  31. usprite_index = spr_bodyup
  32. lsprite_index = spr_legsup
  33. faced = 90
  34. }
  35. if hor_input = 1
  36. {
  37. pimagexscale = -1
  38. usprite_index = spr_bodyside
  39. lsprite_index = spr_legsside
  40. faced = 0
  41. }
  42. if hor_input = -1
  43. {
  44. pimagexscale = 1
  45. usprite_index = spr_bodyside
  46. lsprite_index = spr_legsside
  47. faced = 180
  48. }
  49. if hor_input = -1 and ver_input = -1
  50. {
  51. pimagexscale = 1
  52. usprite_index = spr_heroha
  53. faced = 135
  54. }
  55. if hor_input = -1 and ver_input = 1
  56. {
  57. pimagexscale = 1
  58. usprite_index = spr_herofa
  59. faced = 225
  60. }
  61. if hor_input = 1 and ver_input = -1
  62. {
  63. pimagexscale = -1
  64. usprite_index = spr_heroha
  65. faced = 45
  66. }
  67. if hor_input = 1 and ver_input = 1
  68. {
  69. pimagexscale = -1
  70. usprite_index = spr_herofa
  71. faced = 315
  72. }
  73.  
  74. //check collision
  75. if ( !place_meeting(x+checkX, y+checkY, obj_block) ){
  76. x += checkX;
  77. y += checkY;
  78. }
  79. }
  80. else
  81. {
  82. //(optional) round x and y when not moving
  83. x = round(x);
  84. y = round(y);
  85. walking = 0
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement