Game Development Reference
Working with Tilemaps
In the next two chapters, I introduce you to the world of tile-based games. Whether
you've been playing games since the age of classic role-playing games like Ultima or
you've just recently joined your Facebook friends in Farmville, I'm sure you've already
played a game that uses the tilemap concept for displaying its graphics.
In tilemap games, the graphics consist of a small number of images, called tiles , which
align with each other; placing them on a grid allows you to build rather convincing
game worlds. The concept is very attractive because it conserves memory, compared to
drawing the whole world as individual textures, while still allowing a lot of variety.
This chapter introduces general tilemap concepts by using the simplest tilemaps of all:
orthogonal tilemaps . They're most often built from square tiles, rarely from non-square
rectangular tiles, and typically display the world in a top-down fashion. This chapter dis-
cusses the various display styles of tilemaps, and the next chapter focuses on isometric
tilemaps, building on the tilemap programming basics that you'll learn in this chapter.
What Is a Tilemap?
Tilemaps are 2D game worlds made of individual tiles. You can create large world maps
with just a handful of images that all have the same dimensions. This means tilemaps are
very efficient at conserving memory for large maps (game worlds). It's no wonder that
they first appeared in the early days of computer games. Many classic role-playing
games used square tiles to create fantastic fantasy worlds. These games looked a bit like
the tilemap in Figure 10-1 , which is also a perfect example of an orthogonal tilemap. It