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.” 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值