Advertisement
Guest User

Untitled

a guest
Mar 8th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Information about object: obj_player
  2. Sprite: spr_player_right
  3. Solid: false
  4. Visible: true
  5. Depth: 0
  6. Persistent: false
  7. Parent:
  8. Mask:
  9.  
  10. Create Event:
  11.  
  12. execute code:
  13.  
  14. turning = false;
  15. dir = 1;
  16. spd = 5;
  17.  
  18. Step Event:
  19.  
  20. execute code:
  21.  
  22. /* Gravity */
  23. if (place_free(x,y+1))
  24. {
  25.     gravity_direction = 270;
  26.     gravity = 1;
  27. }
  28. else gravity = 0;
  29.  
  30. /* Controls */
  31. if (keyboard_check_pressed(vk_left))
  32. {
  33.     if (dir = 1)
  34.     {
  35.         sprite_index = spr_player_turnl;
  36.         image_speed = .5;
  37.         turning = true;
  38.     }
  39.    
  40.     dir = -1;
  41. }
  42.  
  43. if (keyboard_check_pressed(vk_right))
  44. {
  45.     if (dir = -1)
  46.     {
  47.         sprite_index = spr_player_turnr;
  48.         image_speed = .5;
  49.         turning = true;
  50.     }
  51.    
  52.     dir = 1;
  53. }
  54.  
  55. if (keyboard_check(vk_left) || keyboard_check(vk_right))
  56. {
  57.     for (i = 0; i <= 8; i += 1)
  58.     {
  59.         if (place_free(x+(spd*dir),y-i))
  60.         {
  61.             x += spd*dir;
  62.             y -= i;
  63.             break;
  64.         }
  65.     }
  66.     image_speed = .5;
  67. }
  68. else if (!turning)
  69. {
  70.     image_speed = 0;
  71.     image_index = 0;
  72. }
  73.  
  74. if (keyboard_check(ord("Z")) && gravity = 0)
  75. {
  76.     vspeed = -12;
  77. }
  78.  
  79. Collision Event with object obj_block:
  80.  
  81. execute code:
  82.  
  83. if (direction = 270 && other.y >= y)
  84. {
  85.     move_contact_solid(270,8);
  86.     vspeed = 0;
  87. }
  88.  
  89. Collision Event with object obj_block_ghost:
  90.  
  91. execute code:
  92.  
  93. if (vspeed >= 0)
  94. {
  95.     with (obj_block_ghost)
  96.     {
  97.         solid = true;
  98.     }
  99.    
  100.     if (other.y >= y && !place_free(x,y+vspeed))
  101.     {
  102.         //move_contact_solid(270,8);
  103.         vspeed = 0;
  104.     }
  105.    
  106.     if (other.y < y && !place_free(x,y+vspeed))
  107.     {
  108.         move_contact_solid(90,8);
  109.         vspeed = 0;
  110.     }
  111. }
  112. else
  113. {
  114.     if (vspeed < 0)
  115.     {
  116.         with(obj_block_ghost)
  117.         {
  118.             solid = false;
  119.         }
  120.     }
  121. }
  122.  
  123. Other Event: Outside Room:
  124.  
  125. execute code:
  126.  
  127. room_restart();
  128.  
  129. Other Event: Animation End:
  130.  
  131. execute code:
  132.  
  133. if (dir = -1) sprite_index = spr_player_left;
  134. else if (dir = 1) sprite_index = spr_player_right;
  135.  
  136. turning = false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement