NeoShade

Ob_Hero STEP Event

Jan 19th, 2020
267
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// Ob_Hero STEP Event
  2.  
  3. // Get player input
  4. key_up = keyboard_check(vk_up) || keyboard_check(ord("W"));
  5. key_dn = keyboard_check(vk_down) || keyboard_check(ord("S"));
  6. key_lf = keyboard_check(vk_left) || keyboard_check(ord("A"));
  7. key_rt = keyboard_check(vk_right) || keyboard_check(ord("D"));
  8.  
  9. // Get input vector
  10. input_dir = point_direction(0, 0, (key_rt - key_lf), (key_dn - key_up));
  11. input_mag = (key_rt - key_lf != 0) || (key_dn - key_up != 0);
  12.  
  13. // Calculate movement vector
  14. x_speed = lengthdir_x((input_mag * walk_speed), input_dir);
  15. y_speed = lengthdir_y((input_mag * walk_speed), input_dir);
  16.  
  17. //
  18. //if (input_mag == 0)
  19. //  { x = round(x); y = round(y); }
  20.  
  21. // Comit movement
  22. player_collision();
  23.  
  24. // Save previous sprite to compare later
  25. var _oldsprite = sprite_index;
  26.  
  27. // Update sprite index
  28. if (input_mag != 0)
  29.     {
  30.     direction = input_dir;
  31.     sprite_index = sprite_walk;
  32.     }
  33. else
  34.     {
  35.     sprite_index = sprite_idle;
  36.     }
  37.  
  38. // Reset local frame whenever sprite index changes
  39. if (_oldsprite != sprite_index)
  40.     { local_frame = 0; }
  41.  
  42. // Update image index
  43. player_animate_sprite();
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.

×