nx_wasm_td.nx
buildroot/runtime/nx_wasm_td.nx
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
imports: nx_nishi_font_core.nx
imported by: nx_wasm_td_gate.nx
structs
| none |
consts
| 7 | const W: i64 = 220 |
| 8 | const H: i64 = 140 |
| 9 | const NC: i64 = 6 |
| 10 | const PY: i64 = 78 // lane center y |
| 11 | const RANGE: i64 = 34 |
| 12 | const DMG: i64 = 3 |
| 13 | const FIRE_CD: i64 = 10 |
| 14 | const SPEED: i64 = 1 |
| 15 | const COST: i64 = 10 |
| 16 | const REWARD: i64 = 4 |
| 17 | const MAXT: i64 = 14 |
| 18 | const O_FB: i64 = 0 // framebuffer W*H i64 |
| 19 | const O_CX: i64 = 246400 // creep x[16] (W*H*8) |
| 20 | const O_CHP: i64 = 246528 |
| 21 | const O_CA: i64 = 246656 // creep on-field[16] |
| 22 | const O_TX: i64 = 246784 // tower x[16] |
| 23 | const O_TY: i64 = 246912 |
| 24 | const O_TC: i64 = 247040 // tower cooldown[16] |
| 25 | const O_ST: i64 = 247168 // scalars[16]: 0=gold 1=lives 2=wave 3=ntowers 4=tick 5=gameover |
| 26 | const O_MSK: i64 = 247296 |
| 27 | const O_STR: i64 = 255488 |
functions
| 29 | func rgb(r: i64, g: i64, b: i64) -> i64 { return (r & 255) | ((g & 255) << 8) | ((b & 255) << 16) } called by 1: render_impl |
| 30 | func iabs(v: i64) -> i64 { if v < 0 { return 0 - v } return v } called by 1: click_impl |
| 32 | func fillr(base: i64, x0: i64, y0: i64, x1: i64, y1: i64, c: i64) -> i64 called by 1: render_impl |
| 44 | func disc(base: i64, cx: i64, cy: i64, rad: i64, c: i64) -> i64 called by 1: render_impl |
| 59 | func spawn_wave(base: i64) -> i64 |
| 68 | func init_impl(base: i64) -> i64 |
| 75 | func click_impl(base: i64, x: i64, y: i64) -> i64 |
| 90 | func tick_impl(base: i64, input: i64) -> i64 |
| 127 | func hud(base: i64, x: i64, off: i64, val: i64, col: i64) -> i64 |
| 141 | func render_impl(base: i64) -> i64 |
| 166 | func init() -> i64 { return init_impl(0) } calls 1: init_impl |
| 167 | func tick(input: i64) -> i64 { return tick_impl(0, input) } calls 1: tick_impl |
| 168 | func render() -> i64 { return render_impl(0) } calls 1: render_impl |
| 169 | func click(x: i64, y: i64) -> i64 { return click_impl(0, x, y) } calls 1: click_impl |
| 170 | func score() -> i64 { let st: *i64 = (0 + O_ST) as *i64; return st[2] } |
| 171 | func fb_off() -> i64 { return O_FB } |
| 172 | func ww() -> i64 { return W } |
| 173 | func hh() -> i64 { return H } |