GenMapToAtlas atlas, tileset | font, atlasX, atlasY


Tile atlas to which the tileset or font will be mapped.

tileset | font

The tileset or font to insert into the atlas. A font is just a special kind of tileset.


The X position in the atlas to insert the tileset.


The Y position in the atlas to insert the tileset.

Think of the tile atlas as one big master bitmap. What you do is take your tileset, which is just a smaller sub-bitmap, and insert it into the tile atlas. Mapping tilesets into your tile atlas is a bit like putting a puzzle together. You must take your tilesets, which are rectangles and fit them into the tile atlas which is a bigger rectangle. The tilesets must not overlap one another.

Once all your tilesets have been fit into one big graphics block, the tile atlas is then loaded into video ram. Once loaded, your graphics are in a format the GPU (graphics processing unit) can use directly with incredible speed.

It is best to draw the tile atlas on paper to help you visualize how the graphics are arranged. On graph paper, draw a rectangle that is proportional in size to your tile atlas. Start with your biggest tileset and draw the tilesets into your atlas rectangle. Note the X and Y coordinates of each tileset within the atlas for use in this command.

The process of laying out the tilesets and tile atlases is a task best suited to humans. Understanding tilesets and atlases is the key to understanding the game engine. Drawing the atlas out on paper, before you start drawing graphics on the screen, will give you an overall view and plan for your game.

Game Engine Overview

Become a Patron