code wiki / (root) / nx_wasm_platformer.nx

nx_wasm_platformer.nx

buildroot/runtime/nx_wasm_platformer.nx

7175 B148 linesdepth 1pulls 1 transitivereach 4 importersview sourcekind librarytopic wasm
docsdependenciesstructsconstsfunctions

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

nx_nishi_font_core.nx nx_wasm_platformer.nx nx_platformer_play.nx nx_platformer_play_gate.nx nx_platformer_term.nx nx_wasm_platformer_gate.nx

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

11const W: i64 = 320
12const H: i64 = 120
13const O_FB: i64 = 0 // W*H i64 packed RGB = 307200 bytes
14const O_ST: i64 = 307200 // state ints (64 i64)
15const O_COIN: i64 = 307712 // coin collected flags (16 i64)
16const O_FOE: i64 = 307840 // foe cleared flags (16 i64)
17const O_MSK: i64 = 307968 // font glyph scratch (base-relative, 16384 bytes)
18const O_STR: i64 = 324352 // HUD number string scratch (64 bytes)
20const NCOIN: i64 = 4
21const NFOE: i64 = 2
22const RUN: i64 = 2 // hero auto-run px/frame
23const GRAV: i64 = 1 // gravity px/frame^2 (integer)
24const IMPULSE: i64 = 9 // jump launch velocity (apex ~45px)
25const GROUNDY: i64 = 92 // hero top-y when standing (hero bottom = 108 = ground band)
26const HEROW: i64 = 12
27const HEROH: i64 = 16
28const COINY: i64 = 58 // floating coin center-y (must jump to reach)
29const EXITX: i64 = 300

functions

32func sget(base: i64, i: i64) -> i64 { let p: *i64 = (base + O_ST) as *i64; return p[i] }
33func sset(base: i64, i: i64, v: i64) -> i64 { let p: *i64 = (base + O_ST) as *i64; p[i] = v; return 0 }
called by 2: init_impltick_impl
34func cget(base: i64, i: i64) -> i64 { let p: *i64 = (base + O_COIN) as *i64; return p[i] }
35func cset(base: i64, i: i64, v: i64) -> i64 { let p: *i64 = (base + O_COIN) as *i64; p[i] = v; return 0 }
called by 2: init_impltick_impl
36func fget(base: i64, i: i64) -> i64 { let p: *i64 = (base + O_FOE) as *i64; return p[i] }
37func fset(base: i64, i: i64, v: i64) -> i64 { let p: *i64 = (base + O_FOE) as *i64; p[i] = v; return 0 }
called by 2: init_impltick_impl
39func coin_x(i: i64) -> i64 { if i == 0 { return 56 } if i == 1 { return 116 } if i == 2 { return 176 } return 236 }
40func foe_x(i: i64) -> i64 { if i == 0 { return 92 } return 206 }
42func rgb(r: i64, g: i64, b: i64) -> i64 { return (r & 255) | ((g & 255) << 8) | ((b & 255) << 16) }
43func fillr(base: i64, x0: i64, y0: i64, x1: i64, y1: i64, c: i64) -> i64
called by 1: render_impl
56func init_impl(base: i64) -> i64
69func tick_impl(base: i64, cmd: i64) -> i64
102func num_str(base: i64, v: i64) -> i64
called by 1: render_impl
114func render_impl(base: i64) -> i64
called by 2: rendermain calls 9: rgbfillrcgetcoin_xfgetfoe_x+3
142func init() -> i64 { return init_impl(0) }
calls 1: init_impl
143func tick(dir: i64) -> i64 { return tick_impl(0, dir) }
calls 1: tick_impl
144func render() -> i64 { return render_impl(0) }
calls 1: render_impl
145func score() -> i64 { let st: *i64 = (0 + O_ST) as *i64; return st[4] }
146func fb_off() -> i64 { return O_FB }
147func ww() -> i64 { return W }
148func hh() -> i64 { return H }