nx_wasm_platformer.nx
buildroot/runtime/nx_wasm_platformer.nx
about
nx_wasm_platformer.nx -- the THIRD sovereign browser game genre: a PLATFORMER auto-runner, pure-Nishi NO-FLOAT,
BASE-RELATIVE (same code native [base=mmap -> PNG] and in our WASM [base=0]). The hero auto-runs right; the
player JUMPS (integer parabola: vy=-IMPULSE, +GRAV/frame) to grab floating coins and clears ground foes;
reaching the exit wins. Structurally distinct from the collect-arcade (gravity + jump arc, not free movement)
and 2048 (slide+merge) -> a third genre on the SAME engine. Integer state machine + integer rasteriser + the
sovereign Nishi font for the HUD score. Exports init/tick/render/score/ww/hh/fb_off = the SAME wasm interface
the arcade/2048 use, so the SAME blit-only html packager serves it. This is the browser delivery of the
Platformer genre the universal-builder catalog scaffolds (nx_game_render / nx_game_scaffold). license_tier: ORIGINAL
dependencies 1 imports · 4 importers
imports: nx_nishi_font_core.nx
imported by: nx_platformer_play.nxnx_platformer_play_gate.nxnx_platformer_term.nxnx_wasm_platformer_gate.nx
structs
| none |
consts
| 11 | const W: i64 = 320 |
| 12 | const H: i64 = 120 |
| 13 | const O_FB: i64 = 0 // W*H i64 packed RGB = 307200 bytes |
| 14 | const O_ST: i64 = 307200 // state ints (64 i64) |
| 15 | const O_COIN: i64 = 307712 // coin collected flags (16 i64) |
| 16 | const O_FOE: i64 = 307840 // foe cleared flags (16 i64) |
| 17 | const O_MSK: i64 = 307968 // font glyph scratch (base-relative, 16384 bytes) |
| 18 | const O_STR: i64 = 324352 // HUD number string scratch (64 bytes) |
| 20 | const NCOIN: i64 = 4 |
| 21 | const NFOE: i64 = 2 |
| 22 | const RUN: i64 = 2 // hero auto-run px/frame |
| 23 | const GRAV: i64 = 1 // gravity px/frame^2 (integer) |
| 24 | const IMPULSE: i64 = 9 // jump launch velocity (apex ~45px) |
| 25 | const GROUNDY: i64 = 92 // hero top-y when standing (hero bottom = 108 = ground band) |
| 26 | const HEROW: i64 = 12 |
| 27 | const HEROH: i64 = 16 |
| 28 | const COINY: i64 = 58 // floating coin center-y (must jump to reach) |
| 29 | const EXITX: i64 = 300 |
functions
| 32 | func sget(base: i64, i: i64) -> i64 { let p: *i64 = (base + O_ST) as *i64; return p[i] } |
| 33 | func sset(base: i64, i: i64, v: i64) -> i64 { let p: *i64 = (base + O_ST) as *i64; p[i] = v; return 0 } |
| 34 | func cget(base: i64, i: i64) -> i64 { let p: *i64 = (base + O_COIN) as *i64; return p[i] } |
| 35 | func cset(base: i64, i: i64, v: i64) -> i64 { let p: *i64 = (base + O_COIN) as *i64; p[i] = v; return 0 } |
| 36 | func fget(base: i64, i: i64) -> i64 { let p: *i64 = (base + O_FOE) as *i64; return p[i] } |
| 37 | func fset(base: i64, i: i64, v: i64) -> i64 { let p: *i64 = (base + O_FOE) as *i64; p[i] = v; return 0 } |
| 39 | func coin_x(i: i64) -> i64 { if i == 0 { return 56 } if i == 1 { return 116 } if i == 2 { return 176 } return 236 } |
| 40 | func foe_x(i: i64) -> i64 { if i == 0 { return 92 } return 206 } |
| 42 | func rgb(r: i64, g: i64, b: i64) -> i64 { return (r & 255) | ((g & 255) << 8) | ((b & 255) << 16) } |
| 43 | func fillr(base: i64, x0: i64, y0: i64, x1: i64, y1: i64, c: i64) -> i64 called by 1: render_impl |
| 56 | func init_impl(base: i64) -> i64 |
| 69 | func tick_impl(base: i64, cmd: i64) -> i64 |
| 102 | func num_str(base: i64, v: i64) -> i64 called by 1: render_impl |
| 114 | func render_impl(base: i64) -> i64 |
| 142 | func init() -> i64 { return init_impl(0) } calls 1: init_impl |
| 143 | func tick(dir: i64) -> i64 { return tick_impl(0, dir) } calls 1: tick_impl |
| 144 | func render() -> i64 { return render_impl(0) } calls 1: render_impl |
| 145 | func score() -> i64 { let st: *i64 = (0 + O_ST) as *i64; return st[4] } |
| 146 | func fb_off() -> i64 { return O_FB } |
| 147 | func ww() -> i64 { return W } |
| 148 | func hh() -> i64 { return H } |