Skip to content
All guides

learn

Gfx

Gfx is a canvas, ink, and sound. That is the game-loop job. The name is Buraaq's.

Not a scene graph. Not an engine you rent. Not Lumen (the operator console). Pixels, a desktop window, keys, and a tone.

The game is that window. The terminal only prints a line or two. Click the window, then play. held is 1 only while that window is focused.

One frame

fn main() {
    canvas(320, 180, "dot")
    ink(12, 18, 32)
    wipe()
    ink(40, 200, 90)
    box(20, 40, 24, 24)
    dash(0, 0, 319, 179)
    flip()
    hush()
}

A loop

fn main() {
    canvas(320, 180, "dot")
    x = 20
    while held("escape") == 0 {
        ink(12, 18, 32)
        wipe()
        ink(40, 200, 90)
        box(x, 60, 24, 24)
        flip()
        if held("right") {
            x = x + 2
        }
        if held("left") {
            x = x - 2
        }
        wait(16)
    }
    hush()
}
APIWhat it does
canvas(w, h, title)Open the framebuffer (and a window on the desktop)
ink / wipe / plot / box / dashColor, clear, point, filled rect, line
flip()Present the frame and pump input
held(name)1 while a key is down (left / space / a…) and the window is focused
pulse()Frames presented since canvas
play / tone / hushFile sound, beep, stop

BURAAQ_GFX_HEADLESS=1 keeps the pixels and skips the window. tone blocks; do not call it every frame.

Play NOVA

stdlib/examples/nova.bq is a neon arena shooter.

buraaq build stdlib/examples/nova.bq dist/nova.exe
dist\nova.exe

Click the NOVA window. Space starts and fires. Arrows or WASD move. Escape quits. Cyan pips are lives; the number is score. One-frame smoke: stdlib/examples/gfx.bq.

Guest today: keep moving state in lists (p[0] = p[0] + 6) and pass slots into helpers. Unique names import themselves.

Live audio and video on a wire are Stream clip / shot.

Next: Hold.