Tiles are 32 × 32 blocks that define a room. A tile does
not move on its own. These may be background, though
the player may interact with them. All tiles belong to one
large tile-set image, and we copy the appropriate tiles as
needed. All graphics used in this game are stored as Portable
Network Graphic (PNG) images. The alpha content in the
PNG format allows transparency, so that sprites can appear
naturally over tiles, or even on top of each other.
To keep things simple, the tile image has “background
only” tiles on rows 1 and 2, meaning that the player moves
over them freely. Next, rows 3 and 4 are collectable items
and interactive things. Something happens when the player
touches one of these tiles. For example, the tile for the red
key means that the player gets this item when he/she reaches
it. The player’s items are then updated to show the new key.
Next, the game engine overwrites this tile in the room array
with the default background tile, so that this key does not
show up again. Thus, it does not make sense to have multiple
red keys within the same game, though the game engine
does not prohibit this. Rows 5 and 6 are obstacles that may
be removed, under the right circumstances. For example, if
the player has collected the red key, then any red lock tiles
that the player touches would simply be removed. However,
any blue lock tiles would not allow the player to pass unless
the blue key has been collected. Finally, rows 7 and 8 are
permanent obstacles, meaning that the player cannot pass
them, and they cannot be removed. This simplifies processing,
since we can examine the tiles’ values and classify the
outcome based on the range of values.
Figure 2 shows a subset of the available tiles. From top
to bottom are background only tiles, items that can be collected,
barriers that might be removed, and barriers that
cannot be removed.