The complete API available to every cartridge. Functions are deterministic unless noted.
initexport function init(): void
Run once when the cartridge starts.
updateexport function update(): void
Run at 60 Hz to update game state and read input.
drawexport function draw(): void
Run after every update to emit drawing commands.
clearclear(color = 0)
Fill the canvas with one palette color.
pixelpixel(x, y, color)
Draw one pixel.
lineline(x0, y0, x1, y1, color)
Draw a line between two points.
rectrect(x, y, width, height, color, fill = false)
Draw an outlined or filled rectangle.
circlecircle(x, y, radius, color, fill = false)
Draw an outlined or filled circle.
texttext(value, x, y, color)
Draw text with the built-in bitmap font.
spritesprite(pixels, width, height, x, y, transparent = 0)
Draw row-major indexed sprite pixels.
mapmap(tiles, columns, tileWidth, tileHeight, spritesheet, sheetColumns, x = 0, y = 0, transparent = 0)
Draw a row-major tile map from an indexed spritesheet.
buttonbutton(input)
Check whether an input is currently held.
buttonPressedbuttonPressed(input)
Check whether an input was pressed this update.
cameracamera(x = 0, y = 0)
Offset subsequent drawing coordinates; call without arguments to reset.
seedseed(value = 1)
Reset the deterministic random sequence.
randomrandom(min = 0, max = 1)
Return the next deterministic random number.
overlapoverlap(ax, ay, aw, ah, bx, by, bw, bh)
Check two axis-aligned rectangles for overlap.
pointInRectpointInRect(px, py, x, y, width, height)
Check whether a point is inside a rectangle.
frameframe()
Return the current deterministic update number.
everyevery(interval, offset = 0)
Return true on a repeating frame interval.
afterafter(frames)
Return true after a frame threshold.
tonetone(frequency, duration = 100, volume = 0.15, wave = "square")
Play one bounded cartridge tone.
sfxsfx(notes, step = 80, volume = 0.15, wave = "square")
Play up to 32 frequencies as a short effect.