Advertisement
MattK_YT

scrMovement

Dec 21st, 2023
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Game Maker 1.19 KB | Software | 0 0
  1. // Los recursos de Script han cambiado para la v2.3.0 Consulta
  2. // https://help.yoyogames.com/hc/en-us/articles/360005277377 para más información
  3. function scrMovement(){
  4. #region Walk/Run
  5. XSpeed = 0;
  6. if input_check("left"){
  7.     XSpeed = -1*Speed;
  8.     state = "Walk"
  9.     image_xscale = -1
  10. }else if input_check("right"){
  11.     XSpeed = Speed;
  12.     state = "Walk"
  13.     image_xscale = 1
  14. }
  15. if input_check_double("left"){
  16.     XSpeed = -1*RunSpeed;
  17.     state = "Run"
  18.     image_xscale = -1
  19. }else if input_check_double("right"){
  20.     XSpeed = RunSpeed;
  21.     state = "Run"
  22.     image_xscale = 1
  23. }
  24.  
  25. YSpeed = 0;
  26. if input_check("up"){
  27.     YSpeed = -1*Speed;
  28.     state = "Walk"
  29. }else if input_check("down"){
  30.     YSpeed = Speed;
  31.     state = "Walk"
  32. }
  33. if input_check_double("up"){
  34.     YSpeed = -1*RunSpeed;
  35.     state = "Run"
  36. }else if input_check_double("down"){
  37.     YSpeed = RunSpeed;
  38.     state = "Run"
  39. }
  40.  
  41. x += XSpeed;
  42. y += YSpeed;
  43.  
  44. #endregion
  45.  
  46.  
  47. //Sets the Players' depth based on their GroundY. We're using GroundY instead of y so that even when they're in the air, they will display in fornt of and behind the right objects.
  48. depth = -1*GroundY;
  49.  
  50. if (XSpeed = 0 and YSpeed = 0){
  51.     state = "Idle" 
  52. };
  53. CheckGridPosition(y, startingY, finishingY)
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement