Collision detection
Collision detection is slightly different for this game as for the previous one. As we use collision instead of per-pixel collision with the sprite-bounding box, we find ourselves in a situation where we might detect a collision where only the sprites' non-transparent pixels are colliding, as shown in the following figure:
However, there is a very easy solution to this problem without resorting to per-pixel or polygonal collision detection; we will use a second transparent sprite to create the zone we really want to use for collision detection.
Player versus environment collisions
In our game, we will use a technique often used in RPG; the player avatar will be made of not only one sprite but of a superposition of sprites. This will allow us to change the armor the avatar wears, change the weapon he uses, his haircut, skin color, and so on, without having to generate all the possible combinations of those variants.
In our game, we will only use two images for the player avatar...