Advertisement
ShaunJS

Basic Collision Prediction in GML

Mar 18th, 2014
3,809
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //horizontal collision
  2. if (place_meeting(x+hsp,y,obj_wall))
  3. {
  4.     while(!place_meeting(x+sign(hsp),y,obj_wall))
  5.     {
  6.         x += sign(hsp);
  7.     }
  8.     hsp = 0;
  9. }
  10. x += hsp;
  11.  
  12. //vertical collision
  13. if (place_meeting(x,y+vsp,obj_wall))
  14. {
  15.     while(!place_meeting(x,y+sign(vsp),obj_wall))
  16.     {
  17.         y += sign(vsp);
  18.     }
  19.     vsp = 0;
  20. }
  21. y += vsp;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement