Tile Maps

Tile Maps

Throughout this book, I have been referring to the 1980s, where my love of games andgame programming started. Although technology has moved on greatly since then, those concepts are still valid to this day.

One of the issues with the old 8-bit (and even 16-bit) home computers and consoleswas the availability of memory (RAM).When creating a platform-based game or role playing game (RPG), it was not feasible(可行的,行的通的) to have large images of each level held in memory. It doesn’t make sense to hold a huge image in memory either, especially when the player is only able to see the portion of the image that fits into their display.

To overcome this issue, tile maps were created. A tile map is usually a two-dimensional grid. Each grid cell contains information about that location within the tile map, such as the ID of the image that should be rendered when that tile location is displayed, as well as information on the type of tile in that location. For example, is this a solid tile that the player cannot move through, such as a wall, or is it an object that could hurt the player should they walk into it?

This method of storing and building environments greatly reduces the amount ofmemory needed to store images and provides benefits later on when you need to know where a player actually is within a map.Although the iPhone is many times more powerful than the old 8-bit machines, memory is still a limited resource, and anything that can reduce the amount of memory being used is a good thing.

Tile maps are usually made up of two elements, as follows:

1. A sprite sheet that contains separate tile images that can be used to build the environment.

2. A map file that specifies which tile should be used in specific tile locations in the map, and so on.This can be done manually, but it becomes complex very quickly as your map gets bigger. 

In Sir Lamorak’s Quest, our hero will be walking around inside a castle. Although we could create the necessary tile maps manually, it’s much easier to draw the tile maps visually, and that is exactly what we are going to do.We cover the creation of tile maps in Chapter 9,“Tile Maps.”

One tool you can use for creating tile maps is Tiled. More information on this free open source application can be found in the section,“Tools.” 


你可能感兴趣的:(iPhone游戏开发)