SHARE
TWEET

Untitled

a guest Sep 15th, 2014 217 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. i = 0;
  2. // Player Input Step
  3. key_right = keyboard_check(vk_right);
  4. key_left = -keyboard_check(vk_left);
  5. key_jump = keyboard_check_pressed(ord('Z'));
  6.  
  7. // Input Action Step
  8. move = key_right + key_left;
  9. hsp = move * movespeed;
  10.  
  11. // Set up gravity
  12. if vsp < 10 then { vsp += grav };
  13.  
  14. // Jumping
  15. if place_meeting(x,y+1,obj_blockOver) or place_meeting(x,y+abs(hsp),obj_blockOver) or place_meeting(x,y+1,obj_passthroughOver) then
  16. {
  17.     if key_jump then
  18.     {
  19.         vsp = key_jump * -jumpspeed
  20.     }
  21. };
  22.  
  23. // Springs
  24. if place_meeting(x,y+1,obj_spring) then
  25. {
  26.     vsp = -10;
  27. };
  28.  
  29. // Apply Changes
  30. if move > 0 then image_index = 0;
  31. if move < 0 then image_index = 1;
  32. if place_meeting(x+hsp,y,obj_blockOver) or x+hsp-6<0 or x+hsp+7>room_width then
  33. {
  34.     if !place_meeting(x+sign(hsp),y-1,obj_blockOver) and not x+sign(hsp)-6<0 and not x+sign(hsp)+7>room_width then
  35.     {
  36.         //Any slope (going up)
  37.         while(!place_meeting(x+sign(hsp),y-1,obj_blockOver) and !(x+sign(hsp)-6<0) and !(x+sign(hsp)+7>room_width) and !(i>=abs(hsp*0.6)))
  38.         {
  39.             x += sign(hsp);
  40.             y -= 1;
  41.             i += 1;
  42.             if i >= abs(hsp*0.6) then break;
  43.         };
  44.     }
  45.     else
  46.     {
  47.         while(!place_meeting(x+sign(hsp),y,obj_blockOver) and not x+sign(hsp)-6<0 and not x+sign(hsp)+7>room_width)
  48.         {
  49.             x += sign(hsp);
  50.         }
  51.     }
  52.     hsp = 0;
  53. };
  54. //45 degree slopes (going down)
  55. if !place_meeting(x+hsp,y+abs(hsp),obj_blockOver) and collision_line(x,y+1,x,y+18,obj_blockOver,false,true) then
  56. {
  57.     x += hsp;
  58.     y += abs(hsp);
  59. };
  60. else
  61. {
  62.     x += hsp;
  63. };
  64.  
  65. if place_meeting(x,y+vsp,obj_blockOver) then
  66. {
  67.     while(!place_meeting(x,y+sign(vsp),obj_blockOver))
  68.     {
  69.         y += sign(vsp);
  70.     };
  71.     vsp = 0;
  72. }
  73. else if place_meeting(x,y+vsp,obj_passthroughOver) and vsp > 0 and !place_meeting(x,y,obj_passthroughOver) then
  74. {
  75.     while(!place_meeting(x,y+sign(vsp),obj_passthroughOver))
  76.     {
  77.         y += sign(vsp);
  78.     };
  79.     vsp = 0;
  80. };
  81. y += vsp;
  82. x = round(x);
  83. y = round(y);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top