Advertisement
rooksword

Top Down Collision Code

Aug 13th, 2019
397
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