Guest User

Input Player Step

a guest
Apr 3rd, 2023
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | Gaming | 0 0
  1. //Set some rules for the aiming cursor
  2. if (input_source_using(INPUT_GAMEPAD))
  3. {
  4. //If we're using a gamepad, limit the cursor to 130px away from the player
  5. //We also set an "elastic" rule so that the cursor automatically springs back towards the player
  6. input_cursor_limit_circle(x, y, 130);
  7. input_cursor_elastic_set(x,y, 0.2);
  8.  
  9. if (!input_check("aim_up"))&&(!input_check("aim_down"))&&(!input_check("aim_left"))&&(!input_check("aim_right"))
  10. {
  11. input_cursor_set(oPlayer1.x, oPlayer1.y,)
  12. oCursor.image_alpha = 0;
  13. rightstick = false;
  14. }
  15. else
  16. {
  17. oCursor.image_alpha = 1;
  18. rightstick = true;
  19. }
  20.  
  21. }
  22. else
  23. {
  24. //If we're not using the gamepad then remove both the limit and the elastic
  25. //This allows the cursor to move totally freely as you'd expect with mouse aiming
  26. input_cursor_elastic_remove();
  27. input_cursor_limit_remove();
  28. }
  29.  
  30.  
  31. //Move the point of aim if the cursor is far enough away from the player
  32. //We perform this distance check so that we don't get twitching when using a gamepad
  33. if (point_distance(x, y, input_cursor_x(), input_cursor_y()) > 10)
  34. {
  35. aim_direction = point_direction(x, y, input_cursor_x(), input_cursor_y());
  36. image_angle = aim_direction;
  37. if (input_source_using(INPUT_GAMEPAD))
  38. {
  39. if(shoot_timer = 0)
  40. {
  41. shoot_timer = 1*shoot_rate; //shoot_timer controls the rate of fire
  42. image_speed = 20;
  43. //The speed of the bullet is set in the Create event for obj_example_bullet
  44. var _xx = x + lengthdir_x(28, image_angle);
  45. var _yy = y + lengthdir_y(28, image_angle);
  46.  
  47. with(instance_create_layer(_xx, _yy, "Shots", oShot))
  48. {
  49. input_vibrate_constant(0.05, 0, 5)
  50. creator = other.id;
  51. direction = other.aim_direction;
  52. }
  53. }
  54.  
  55.  
  56.  
  57. if (shoot_timer > 0)
  58. {
  59. --shoot_timer;
  60. image_speed = 0;
  61. }
  62. }
  63. else
  64. {
  65. //Handle shooting
  66. if (shoot_timer > 0)
  67. {
  68. --shoot_timer;
  69. image_speed = 0;
  70. }
  71. else if (input_check("shoot"))
  72. {
  73. shoot_timer = 1*shoot_rate; //shoot_timer controls the rate of fire
  74. image_speed = 20;
  75. //The speed of the bullet is set in the Create event for obj_example_bullet
  76. var _xx = x + lengthdir_x(28, image_angle);
  77. var _yy = y + lengthdir_y(28, image_angle);
  78. with(instance_create_layer(_xx, _yy, "Shots", oShot))
  79. {
  80. input_vibrate_constant(0.05, 0, 5)
  81. creator = other.id;
  82. direction = other.aim_direction;
  83.  
  84. }
  85. }
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment