Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. ///Initialize Variables
  2. grav = 1;
  3. hsp = 0;
  4. vsp = 1;
  5. jumpspeed = 10;
  6. movespeed = 15;
  7.  
  8. --------------------------------------------------
  9.  
  10. //Get the player's input
  11. key_right = keyboard_check(vk_right);
  12. key_left = -keyboard_check(vk_left);
  13. key_jump = keyboard_check_pressed(vk_space);
  14.  
  15. //React to inputs
  16. move = key_left + key_right;
  17. hsp = move * movespeed;
  18. if (vsp < 10) vsp += grav;
  19.  
  20.  
  21. if (place_meeting(x,y+1,obj_scenario))
  22. {
  23. vsp = key_jump * -jumpspeed
  24. }
  25.  
  26. //Horizontal Collision
  27. if (place_meeting(x+hsp,y,obj_scenario))
  28. {
  29. while(!place_meeting(x+sign(hsp),y,obj_scenario))
  30. {
  31. x += sign(hsp);
  32. }
  33. hsp = 0;
  34. }
  35. x += hsp;
  36.  
  37. //Vertical Collision
  38. if (place_meeting(x,y+vsp,obj_scenario))
  39. {
  40. while(!place_meeting(x,y+sign(vsp),obj_scenario))
  41. {
  42.  
  43. y += sign(vsp);
  44. }
  45. vsp = 0;
  46. }
  47. y += vsp;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement