code wiki / (root) / nx_wasm_td.nx

nx_wasm_td.nx

buildroot/runtime/nx_wasm_td.nx

7261 B173 linesdepth 1pulls 1 transitivereach 1 importersview sourcekind librarytopic wasm
docsdependenciesstructsconstsfunctions

about

nx_wasm_td.nx -- BROWSER-PLAYABLE sovereign Tower-Defence: BASE-RELATIVE integer core, runs native (-> PNG) AND in the browser (base = 0). NO float, NO JS logic, NO canvas drawing. CLICK to place a tower (costs gold) near the lane; towers auto-fire at creeps in range; creeps walk the lane to your base (lose a life if they reach it); kills pay gold; escalating waves. Adds a click(x,y) export (the shim maps a canvas click to game coords). init()/tick(input)/render()/score()/ww()/hh()/fb_off()/click(x,y) = the wasm interface. licen_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_nishi_font_core.nx nx_wasm_td.nx nx_wasm_td_gate.nx

imports: nx_nishi_font_core.nx

imported by: nx_wasm_td_gate.nx

structs

none

consts

7const W: i64 = 220
8const H: i64 = 140
9const NC: i64 = 6
10const PY: i64 = 78 // lane center y
11const RANGE: i64 = 34
12const DMG: i64 = 3
13const FIRE_CD: i64 = 10
14const SPEED: i64 = 1
15const COST: i64 = 10
16const REWARD: i64 = 4
17const MAXT: i64 = 14
18const O_FB: i64 = 0 // framebuffer W*H i64
19const O_CX: i64 = 246400 // creep x[16] (W*H*8)
20const O_CHP: i64 = 246528
21const O_CA: i64 = 246656 // creep on-field[16]
22const O_TX: i64 = 246784 // tower x[16]
23const O_TY: i64 = 246912
24const O_TC: i64 = 247040 // tower cooldown[16]
25const O_ST: i64 = 247168 // scalars[16]: 0=gold 1=lives 2=wave 3=ntowers 4=tick 5=gameover
26const O_MSK: i64 = 247296
27const O_STR: i64 = 255488

functions

29func rgb(r: i64, g: i64, b: i64) -> i64 { return (r & 255) | ((g & 255) << 8) | ((b & 255) << 16) }
called by 1: render_impl
30func iabs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
called by 1: click_impl
32func fillr(base: i64, x0: i64, y0: i64, x1: i64, y1: i64, c: i64) -> i64
called by 1: render_impl
44func disc(base: i64, cx: i64, cy: i64, rad: i64, c: i64) -> i64
called by 1: render_impl
59func spawn_wave(base: i64) -> i64
called by 2: init_impltick_impl
68func init_impl(base: i64) -> i64
called by 3: click_implinitmain calls 1: spawn_wave
75func click_impl(base: i64, x: i64, y: i64) -> i64
called by 2: clickmain calls 2: init_impliabs
90func tick_impl(base: i64, input: i64) -> i64
called by 2: tickmain calls 1: spawn_wave
127func hud(base: i64, x: i64, off: i64, val: i64, col: i64) -> i64
called by 1: render_impl calls 1: nf_draw_text_mem
141func render_impl(base: i64) -> i64
called by 2: rendermain calls 4: rgbfillrdischud
166func init() -> i64 { return init_impl(0) }
calls 1: init_impl
167func tick(input: i64) -> i64 { return tick_impl(0, input) }
calls 1: tick_impl
168func render() -> i64 { return render_impl(0) }
calls 1: render_impl
169func click(x: i64, y: i64) -> i64 { return click_impl(0, x, y) }
calls 1: click_impl
170func score() -> i64 { let st: *i64 = (0 + O_ST) as *i64; return st[2] }
171func fb_off() -> i64 { return O_FB }
172func ww() -> i64 { return W }
173func hh() -> i64 { return H }