@ohnrshyp/brick-drohp
v1.0.1
Published
Terminal Brick Drohp built with Ohnrscript
Readme
BrickDrohp.Ohn
A playable Brick Drohp written in Ohnrscript — the same i32-only, no-GC, no-floats, no-dynamic-heap language used to build ohn-kernel.
The engine lives in one file: brick-drohp.ohn. A small HTML/canvas shim reads engine state and paints it — the same shape of split the V-language Doom port has with SDL.
Play it:
Open playground.built.html directly in a browser or node play.js for terminal. No server, no dependencies, no build step — one file, ~18KB, drop it anywhere. It also runs from file://, so you can double-click it.
Controls:
P pause R restart ← / → move ↓ soft drop ↑ rotate clockwise Z rotate counter-clockwise Space hard drop
</td>
<td valign="top" width="43%">
<h2>Architecture in one paragraph</h2>
<p>
<code>brick-drohp.ohn</code> is one file with 37 functions, no <code>require()</code>, no arrays literals, no <code>switch</code>, no closures, no floats. The board is a 200-byte <code>Uint8Array</code> (10×20, one byte per cell).
</p>
<br>
<p>
The 7 tetrominoes × 4 rotations are 28 entries in a module-level <code>Int32Array</code>, each a 16-bit mask over a 4×4 box. The RNG is a hand-rolled xorshift32 driving a Fisher-Yates 7-bag. Gravity is an integer frame counter. All arithmetic is <code>| 0</code>-cast.
</p>
<br>
<p>
The compiled <code>brick-drohp.js</code> is a 1:1 translation of the source — the V8 backend injects no runtime. The browser shim is deliberately logic-free: it reads state via query functions (<code>getCell</code>, <code>getScore</code>, <code>getActivePieceType</code>, ...) and issues movement calls (<code>moveLeft</code>, <code>rotateCW</code>, <code>hardDrop</code>, ...). Game logic lives entirely in <code>brick-drohp.ohn</code>.
</p>
</td>Building from source
Rebuilding brick-drohp.js and playground.built.html requires the Ohnrscript compiler, which lives in the main Ohnrscript repo. Assuming a clone at ../ohnrscript alongside this one:
# Compile the engine to JS
node ../ohnrscript/compiler/scripts/compile.js brick-drohp.ohn -o brick-drohp.js
# Run the tests against the compiled output
npx jest
# Rebuild the standalone browser file
node build.js
What's in this repo
| File | What it is |
| :---- | :---- |
| brick-drohp.ohn | The engine. 37 functions. Board, tetromino shapes (all 4 rotations), collision, movement, rotation, gravity, 7-bag randomizer (xorshift32), line-clear, scoring, leveling. Written in the strict Ohnrscript subset defined in developer_guide.md. |
| brick-drohp.js | Compiled output of brick-drohp.ohn via the V8 backend. Generated, not hand-written — committed here because rebuilding requires the separate Ohnrscript compiler repo. |
| playground.html | The browser shim template — <canvas> rendering, keydown handlers, requestAnimationFrame loop calling tick(). |
| playground.built.html | The hostable artifact. build.js inlines the compiled engine into playground.html to produce this single self-contained file. |
| build.js | Node script that inlines the compiled engine into the shim template. |
| play.js | Terminal frontend for the same engine — a second, logic-free shim reading state from brick-drohp.js and painting the board with ANSI 256-color escapes. Run with node play.js. Requires a TTY. |
| tests/brick-drohp.test.js | 16 jest tests running against the compiled JS — shape integrity across all rotations, wall collisions, gravity and locking, line-clear math (including the 1200-point Brick Drohp bonus), leveling, 7-bag correctness, game-over handling. |
