← back to Forge

Forge Console

target: LOCKE 480×270 runs live as you type exports a real game.cpp

Your program lives in the Forge up top, and it autosaves as you type, so it is here when you come back. Click a building block on the right and it drops straight into your code, highlighted so you can see where it went, and one Undo takes it back. The reference Forge underneath is a scratchpad: try a recipe or a wild idea there without touching your program. Reset brings back the Hello World starter when you want to begin again. Click a screen and drive with the arrow keys, then Export game.cpp to save a real Locke cartridge: it downloads as an ordinary file you own, so copy it onto a USB stick, plug the stick into a Locke, and the console loads and plays it. No app, no account, no internet.

↓ Download the Locke primer A one-page spec of Locke and its controls. Read it to learn the system and write your own, or vibe-code with it: hand it to a coding model and it builds a game that runs here and compiles to a real cartridge.
Locke basics, the system you are writing for
Screen 480 × 270 pixels, 16:9. Origin (0,0) is top-left, x grows right, y grows down. W and H hold 480 and 270.
Colour rgb(r, g, b), each 0 to 255. Every pixel is one 0xAARRGGBB value, no palette.
The loop update(ctx) runs about 60 times a second and draws the whole frame. init(ctx) runs once at the start, on_exit(ctx) at the end.
Fair motion multiply speeds by ctx.dt, the seconds since the last frame. ctx.millis is the time since start.
Two pads ctx.pad[0] and ctx.pad[1]. Test a button with ctx.pad[0] & LK_PAD_LEFT (also RIGHT, UP, DOWN, A, B, X, Y, START, SELECT).
Draw fill, rect, frame, line, circle, pixel, number, text. Each takes ctx first.
Words text(ctx, x, y, "HI", rgb(255,255,255), 3) writes letters and digits. The last number is the size.
Sound ctx.sfx(SFX_SCORE) for an effect, ctx.music(MUS_PLAY) for a loop, ctx.music(MUS_NONE) to stop.
Memory saveInt(ctx, "best", n) and loadInt(ctx, "best", 0) keep a number through a power-off.
your program
editor · your programautosaved
1
preview · your program
Drive: click the screen, then arrows = move · Z = A · X = B · A = X · S = Y · Enter = Start · Shift = Select. A gamepad works too.
Your program runs here. It autosaves as you type.
building blocks · copy + paste
Reference Forge
a scratchpad. recipes and experiments land here. copy from it, paste into your program above.
reference forge · scratchpad
1
preview · scratchpad
Click a recipe to try it here, or copy your program down. Your program up top stays safe.
recipes · the learning ladder