Maps
BASEMAP · META · SIZE · TILEMAP · TILES · TILESET · TILESIZE · mapdata · mapheight · mapmeta · mapwidth
BASEMAP
A .map.json to start from: its size, tiles and layers.
BASEMAP file
Parameters
- file AS STRING
Example
SCREEN 320, 240
ground = (23, 20):INTEGER
TILEMAP "level"
BASEMAP "level.map.json"
TILES 0 !! into(ground)
END TILEMAP
// The basemap gave the size and filled the grid: here, its top row
CREATE MAP "level" !! layer_to(0)
SET LAYER 3
PRINT ground(0)
Notes
You can write it only inside TILEMAP.
META
A layer of text for each tile, which isn’t drawn: what a tile is, for the game to look up.
META name
Also documents: from, into
Parameters
- name AS STRING - What the layer is called.
After !!
- from(grid) - Draw this layer from a grid the program keeps,
grid(y, x). - into(grid) - Fill this grid from the BASEMAP’s layer.
Example
SCREEN 320, 240
ground = (23, 20):INTEGER
markers = (23, 20):STRING
TILEMAP "level"
BASEMAP "level.map.json"
TILES 0 !! into(ground)
META "Metadata" !! into(markers)
END TILEMAP
// Find the player's start in the metadata layer
FOR y = 0 ... 22
FOR x = 0 ... 19
IF markers(y, x) = "P" THEN PRINT "player starts at", x, y
END FOR
END FOR
Notes
You can write it only inside TILEMAP.
SIZE
How many tiles across and down.
SIZE width, height
Parameters
- width AS NUMBER
- height AS NUMBER
Example
SCREEN 320, 240
LOADIMG "greyscale.png", "tiles"
floor = (5, 8):INTEGER
TILEMAP "room"
TILESET "tiles"
TILESIZE 32
// 8 tiles across, 5 down: the grid is 5 rows of 8
SIZE 8, 5
TILES 0 !! from(floor)
END TILEMAP
CREATE MAP "room" !! layer_to(0)
SET LAYER 3
PRINT mapwidth(0), mapheight(0)
Notes
You can write it only inside TILEMAP.
TILEMAP
Describes a map of tiles, for CREATE MAP to show: its tile set and size, then its layers, each drawn from a grid the program keeps (!! from) or filled from a BASEMAP (!! into). UPDATE MAP shows what changed in the grids.
TILEMAP name
...
END TILEMAP
Parameters
- name AS STRING - What the map is called, for
CREATE MAPandUPDATE MAP.
Examples
SCREEN 320, 240
LOADIMG "greyscale.png", "tiles"
ground = (15, 20):INTEGER
FOR x = 0 ... 19
ground(14, x) = 1
END FOR
TILEMAP "level1"
TILESET "tiles"
TILESIZE 32
SIZE 20, 15
TILES 0 !! from(ground)
END TILEMAP
CREATE MAP "level1" !! layer_to(1)
SET LAYER 3
PRINT mapwidth(1), mapheight(1)
SCREEN 320, 240
ground = (23, 20):INTEGER
decor = (23, 20):INTEGER
markers = (23, 20):STRING
TILEMAP "level"
BASEMAP "level.map.json"
TILES 0 !! name("ground") into(ground)
TILES 1 !! name("decor") into(decor)
META "Metadata" !! into(markers)
END TILEMAP
CREATE MAP "level" !! layer_to(1)
SET LAYER 3
PRINT ground(8, 9), decor(0, 0), markers(8, 9)
Notes
Opens a block I run once. Inside it you can write BASEMAP, META, SIZE, TILES, TILESET and TILESIZE.
TILES
A layer of tiles, by its place among the map’s layers, from 0.
TILES index
Also documents: from, into, name
Parameters
- index AS NUMBER - Its place: 0 is drawn first.
After !!
- from(grid) - Draw this layer from a grid the program keeps,
grid(y, x). - into(grid) - Fill this grid from the BASEMAP’s layer.
- name(text AS STRING) - What the layer is called, for
UPDATE MAPto name it by.
Example
SCREEN 320, 240
LOADIMG "greyscale.png", "tiles"
bg = (15, 20):INTEGER
fg = (15, 20):INTEGER
TILEMAP "level1"
TILESET "tiles"
TILESIZE 32
SIZE 20, 15
TILES 0 !! name("bg") from(bg)
TILES 1 !! name("fg") from(fg)
END TILEMAP
CREATE MAP "level1" !! layer_to(1...2)
// Change the grids, then show the changes at once
bg(3, 5) = 2
fg(4, 6) = 1
UPDATE MAP "level1"
SET LAYER 3
PRINT bg(3, 5), fg(4, 6)
Notes
You can write it only inside TILEMAP.
TILESET
The image the tiles are cut from.
TILESET image
Parameters
- image AS STRING
Example
SCREEN 320, 240
LOADIMG "greyscale.png", "tiles"
floor = (2, 4):INTEGER
TILEMAP "room"
// The image the tiles are cut from, by the name LOADIMG gave it
TILESET "tiles"
TILESIZE 32
SIZE 4, 2
TILES 0 !! from(floor)
END TILEMAP
CREATE MAP "room" !! layer_to(0)
SET LAYER 3
PRINT mapwidth(0), "tiles across"
Notes
You can write it only inside TILEMAP.
TILESIZE
How big a tile is, in pixels: square when it’s given one number.
TILESIZE width [, height]
Parameters
- width AS NUMBER
- height AS NUMBER = NULL
Example
SCREEN 320, 240
LOADIMG "greyscale.png", "tiles"
floor = (2, 4):INTEGER
TILEMAP "wide"
TILESET "tiles"
// 32 across, 16 down: a tile that isn't square
TILESIZE 32, 16
SIZE 4, 2
TILES 0 !! from(floor)
END TILEMAP
CREATE MAP "wide" !! layer_to(0)
SET LAYER 3
PRINT mapwidth(0), mapheight(0)
Notes
You can write it only inside TILEMAP.
mapdata
The cells of a map that carry data, inside a region: each with x, y, its meta and its tile.
mapdata(region AS VECTOR, layer AS NUMBER = NULL)
Also documents: layer
Parameters
- region AS VECTOR - Two corners, as
(x1, y1) -> (x2, y2). - layer AS NUMBER = NULL
After !!
- layer(number AS NUMBER) - Which layer’s map. The one being drawn on when left out.
Example
SCREEN 320, 240
CREATE MAP "level.map.json" !! layer_to(0)
SET LAYER 3
FOR cell = MAPDATA((8, 7) -> (10, 9), 0)
PRINT cell.x, cell.y, cell.meta
END FOR
PRINT "done"
mapheight
Returns the height of a tilemap layer in tiles. Pair it with MAPWIDTH for full map dimensions — iteration bounds, boundary checks, centering math. Returns 0 if the specified layer isn’t a map layer or doesn’t exist.
mapheight(layer_id)
Parameters
- layer_id - The layer number to query (must be a tilemap layer created with CREATE MAP)
Example
SCREEN 320, 240
CREATE MAP "level.map.json" !! layer_to(0)
SET LAYER 3
PRINT mapheight(0), "tiles down"
mapmeta
Returns the metadata character at the specified tile coordinates in the current map layer. Returns an empty string if no metadata exists at that position or if coordinates are out of bounds. Metadata is placed in the Map Editor using the Metadata layer. Use this to check specific tile positions for markers like spawn points, triggers, or item locations.
It can be written mapmeta(x, y) or mapmeta(coord).
mapmeta(x, y = NULL)
Parameters
- x - X tile coordinate (0-based)
- y = NULL - Y tile coordinate (0-based)
Example
SCREEN 320, 240
CREATE MAP "level.map.json" !! layer_to(0)
SET LAYER 0
start = mapmeta(9, 8)
key = mapmeta((9, 5))
empty = mapmeta(0, 0) = ""
SET LAYER 3
PRINT start, key, empty
mapwidth
Returns the width of a tilemap layer in tiles. Useful for iteration bounds, boundary checks, dynamic camera centering, anything that needs to know how big the map is. Returns 0 if the specified layer isn’t a map layer or doesn’t exist.
mapwidth(layer_id)
Parameters
- layer_id - The layer number to query (must be a tilemap layer created with CREATE MAP)
Example
SCREEN 320, 240
CREATE MAP "level.map.json" !! layer_to(0)
SET LAYER 3
PRINT mapwidth(0), "tiles across"
// Not a map layer
PRINT mapwidth(5)