Collision detection
This is a very important part of our framework, and we will start by looking at how we will do this for the case of a sprite colliding with the tile map. This situation has the advantage of being easier than the general case, but still using most of the same basic ideas. We will, however, stick with axis-aligned elements. This means that collision with rotated elements will not be shown here.
Colliding with tile maps
Finding which tiles of a tile map collide with a sprite can be divided into two parts. First find a box representing the intersection of the two. Then, list all the sprites in this box. A list of some of the possible intersections is shown in red in the following figure:
This may at first seem complicated, but it becomes much easier if you consider that it's the exact same problem as finding two one-dimensional intersections (one for each axis).
You may not have realized it, but we used a simplified version of one-dimensional intersections in our Frogger clone...