Maps

Map(args ...any)

Draws a rectangular region of the map to the screen.

Parameters:

NameTypeDescription
mx, myint (optional)Map tile coordinates to start reading from (default 0, 0).
sx, syint (optional)Screen pixel coordinates to draw at (default 0, 0).
w, hint (optional)Dimensions in tiles (default 16x16).
layersint (optional)Bitfield to filter drawn sprites by their flags (0 = draw all).

Example:

p8.Map()                          // draw the default 16x16 tile region at (0,0)
p8.Map(0, 0, 0, 0, 32, 32)        // draw a 32x32 tile region
p8.Map(0, 0, 0, 0, 32, 32, 1)     // only draw tiles whose sprite has flag 0 set

Map() caches its composited tile image across frames for performance; see SetMapCacheEnabled if you need to disable that for a map that changes every frame.

See also: Drawing Maps

Mget[C, R Number](column C, row R) int

Returns the sprite number placed at the given map column/row.

Parameters:

NameTypeDescription
column, rowNumberMap tile coordinates to read from.

Example:

sprite := p8.Mget(5, 3)

Mset[C, R, S Number](column C, row R, sprite S)

Sets the sprite number at the given map column/row.

Parameters:

NameTypeDescription
column, rowNumberMap tile coordinates to write to.
spriteNumberSprite number to place at that tile.

Example:

p8.Mset(5, 3, 1) // place sprite 1 at column 5, row 3

See also: Map Data