tynt
    Preparing search index...

    Cartridge API

    The complete API available to every cartridge. Functions are deterministic unless noted.

    export function init(): void

    Run once when the cartridge starts.

    export function update(): void

    Run at 60 Hz to update game state and read input.

    export function draw(): void

    Run after every update to emit drawing commands.

    clear(color = 0)

    Fill the canvas with one palette color.

    pixel(x, y, color)

    Draw one pixel.

    line(x0, y0, x1, y1, color)

    Draw a line between two points.

    rect(x, y, width, height, color, fill = false)

    Draw an outlined or filled rectangle.

    circle(x, y, radius, color, fill = false)

    Draw an outlined or filled circle.

    text(value, x, y, color)

    Draw text with the built-in bitmap font.

    sprite(pixels, width, height, x, y, transparent = 0)

    Draw row-major indexed sprite pixels.

    map(tiles, columns, tileWidth, tileHeight, spritesheet, sheetColumns, x = 0, y = 0, transparent = 0)

    Draw a row-major tile map from an indexed spritesheet.

    button(input)

    Check whether an input is currently held.

    buttonPressed(input)

    Check whether an input was pressed this update.

    camera(x = 0, y = 0)

    Offset subsequent drawing coordinates; call without arguments to reset.

    seed(value = 1)

    Reset the deterministic random sequence.

    random(min = 0, max = 1)

    Return the next deterministic random number.

    overlap(ax, ay, aw, ah, bx, by, bw, bh)

    Check two axis-aligned rectangles for overlap.

    pointInRect(px, py, x, y, width, height)

    Check whether a point is inside a rectangle.

    frame()

    Return the current deterministic update number.

    every(interval, offset = 0)

    Return true on a repeating frame interval.

    after(frames)

    Return true after a frame threshold.

    tone(frequency, duration = 100, volume = 0.15, wave = "square")

    Play one bounded cartridge tone.

    sfx(notes, step = 80, volume = 0.15, wave = "square")

    Play up to 32 frequencies as a short effect.