kurtisalanpoe

making col work

May 14th, 2020
316
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// @description player_read_controls()
  2. /// @function player_read_controls
  3. //Read Controls and returns movement_direction accordingly
  4.  
  5. if gamepad_is_connected(0) gamepad_set_axis_deadzone(0, 0.15);
  6. var haxis = gamepad_axis_value(0, gp_axislh);
  7. var vaxis = gamepad_axis_value(0, gp_axislv);
  8. direction = point_direction(0, 0, haxis, vaxis);
  9. //speed = point_distance(0 ,0, haxis, vaxis) * 5;
  10.  
  11. //Left Right Movement
  12. var _x_speed=0;
  13.  
  14.  
  15. _x_speed = haxis;
  16.  
  17.  
  18. //Up Down Movement
  19. var _y_speed=0;
  20.  
  21.  
  22.  
  23.  
  24. _y_speed += vaxis;
  25.  
  26. if (_y_speed !=0 && direction > 225 && direction < 315)
  27. {
  28.     sprite_index = spr_down_run;
  29. }
  30. else if (_y_speed !=0 && direction > 45 && direction < 135)
  31. {
  32.     sprite_index = spr_run_up;
  33. }
  34.  
  35. else if (_x_speed !=0 && direction > 315)
  36. {
  37.     sprite_index = spr_run_right;
  38. }
  39.  
  40. else if (_x_speed !=0 && direction < 45)
  41. {
  42.     sprite_index = spr_run_right;
  43. }
  44.  
  45. else if (_x_speed !=0 && direction > 135 && direction < 225 )
  46. {
  47.     sprite_index = spr_run_left;
  48. }
  49. else
  50. {
  51.     sprite_index = spr_forward_town
  52. }
  53.  
  54.  
  55. //return movement direction
  56. if(_x_speed != 0 || _y_speed != 0)
  57. {
  58.    return(point_direction(0,0,_x_speed,_y_speed)); //At least one direction is being pressed; return movement direction
  59. }
  60. else
  61.     return(-1);
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×