daily pastebin goal
10%
SHARE
TWEET

Untitled

a guest Jan 17th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///physics()
  2. //Physics for actors
  3.  
  4. //grav increases the player's downwards speed by raising vsp.
  5. vsp += grav;
  6.  
  7.  
  8. //Friction will reduce horizontal speed.
  9. hsp -= frict * sign(hsp) * grounded;
  10.  
  11. //If hsp is lower than the friction value, it just sets hsp to 0.
  12. if (abs(hsp) < frict)
  13. {
  14.     hsp = 0;
  15. }
  16.  
  17. //Object carrying function.
  18. carry();
  19.  
  20. //Adds hspCarry and vspCarry to hsp and vsp.
  21. vsp += vspCarry;
  22. hsp += hspCarry;
  23.  
  24. //Collision with walls. The player's position is changed after each collision function.
  25. vsp = floor_collision(vsp);
  26. hsp = wall_collision(hsp);
  27.  
  28. //Stops the player if it is going outside the horizontal edge of the screen.
  29. if (oob_horizontal(x + hsp))
  30. {
  31.     hsp = 0;
  32. }
  33.  
  34. //Objects have a terminal velocity. That is to say, there's a cap on how fast an object can move down.
  35. vsp = min(8, vsp);
  36.  
  37. //Objects have a terminal velocity.
  38. vspFinal = vsp;
  39. hspFinal = hsp;
  40.  
  41. //Actually moves the object.
  42. y += vspFinal;
  43. x += hspFinal;
  44.  
  45. //Checks if an object is on the ground.
  46. grounded = bottom(bbox_bottom + 1, ground);
  47.  
  48. //These variables control the speed the object is moving at if it's on top of something.
  49. hspCarry = 0;
  50. vspCarry = 0;
RAW Paste Data
Top