Note that this routine handles applying gravity, applying velocity to position, background collision and response to those collisions.
Code: Select all
For Object in All Objects
Apply gravity to Object Y velocity
Apply Y velocity to Y position
Calculate bounds
Check Y collision with background
If a collision occured
Correct Y position
Recalculate top and bottom bounds
Apply X velocity to X position
Recalculate left and right bounds
Check X collision with background
If a collision occured
Correct X position
Recalculate left and right bounds
Thoughts? How do you all implement platformer-style collision detection?
Thanks!