Book Image

Lua Game Development Cookbook

By : Mario Kasuba, Mário Kašuba
Book Image

Lua Game Development Cookbook

By: Mario Kasuba, Mário Kašuba

Overview of this book

Table of Contents (16 chapters)
Lua Game Development Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Using tiles and tilesets in the game


Tiles are usually referred to as small subimages that are part of a bigger image. Tiles usually have the same size, so they are easily compacted into one rectangular area. You can see tiles mostly in 2D games, especially in platform games, RPGs and even 3D action games. The rectangular property makes tiles very efficient in the question of accessing specific subimages from a large tileset. You can store the whole tileset into the graphical memory, and with the knowledge of the subimage positions, you can easily select the tiles you need.

You can observe that many small game animations consist of a connected set of tiles—called tileset. Tilesets can define an animation as an ordered list of tile indices. Tile indices are often accompanied with destination coordinates so you can make an animated movement with the same tile.

The main advantage of the Lua language is that it has excellent support for structural data description. Therefore, you can use Lua tables...