Collision Practice

First, download the project

Then, follow the TODO comments in the WorldObject class to add collision detection. The order you should do this in is:

  1. Calculate the AABB for each object, assuming no rotation (Don't forget to use the TextureOrigin and Position and Width/Height of the texture to do this!)
  2. Do collision detection based only on AABBs, assuming no rotation.
  3. Do per-pixel collision detection, assuming no rotation. Only compare pixels that are in the AABB intersection!
  4. Modify the AABB calculation to handle rotation. Rotate the 4 corners of the AABB and calculate a new AABB that contains these points
  5. (You are unlikely to get to this final step, but just in case ...) Modify the per-pixel intersection to handle rotated objects as well. For each non-transparent pixel in object A, find the corresponding point in the object space of object B, and then check to see if that point is non-transparent in object B.