Skip to content
This repository was archived by the owner on Jan 26, 2022. It is now read-only.

Loading tilemaps

TheLastMillennial edited this page Apr 4, 2019 · 2 revisions

As said in the previous section, the tileset is stored in an appvar, so be sure to transfer TILES.8xp to your calculator. We need to 'load' the appvar data in our ICE program, and that is what the token LoadData( is for. Copy the data from the text file and put the token in front of it. This returns a pointer to the table with pointers to the sprites. If you have no idea what that means; no problem, you don't need to understand it. However, you need to store this pointer into a variable, which we will use in DefineTilemap(. The syntax for DefineTilemap( is this:

DefineTilemap(TILE_HEIGHT,TILE_WIDTH,DRAW_HEIGHT,DRAW_WIDTH,TYPE_WIDTH,TYPE_HEIGHT,TILEMAP_HEIGHT,TILEMAP_WIDTH,Y,X,PTR[,"MAP_DATA"])
Argument Explanation
TILE_HEIGHT / TILE_WIDTH Individual tile pixel height / width (Respectively).
DRAW_HEIGHT / DRAW_WIDTH Number of tiles per row / column to draw (Respectively).
TYPE_WIDTH / TYPE_HEIGHT See the commands.html file for options.
Y / X The Y / X pixel location of tilemap (Respectively).
PTR Pointer to tiles (more information below).
"MAP_DATA" Pointer to indexed map array (more information below).

The most important argument is the PTR one; that must be the variable holding the pointer from LoadData(. You can get the "MAP_DATA" from tilemaps.txt, which we already converted earlier. This function returns a pointer to the tilemap struct, which should be used in the tilemap functions.

Clone this wiki locally