Skip to content

Instantly share code, notes, and snippets.

@jpleau
Created June 11, 2013 00:09
Show Gist options
  • Save jpleau/5753572 to your computer and use it in GitHub Desktop.
Save jpleau/5753572 to your computer and use it in GitHub Desktop.
Check collision for X:
If there's collision, xVelocity = 0
Check colision for Y:
If there's collision, yVelocity = 0
If there was a collision on X but not on Y, check if the top or bottom (depending on our position) is free, and if yes, yVelocity = -1 or 1 (depending on our position vs the box that we collided on)
If there was a collision on Y but not on X, check if the left or right (depending on our position) is free, and if yes, xVelocity = -1 or 1 (again depending on our position vs the box that we collided on)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment