code wiki / (root) / nx_wasm_city.nx

nx_wasm_city.nx

buildroot/runtime/nx_wasm_city.nx

5956 B140 linesdepth 1pulls 1 transitivereach 1 importersview sourcekind librarytopic wasm
docsdependenciesstructsconstsfunctions

about

nx_wasm_city.nx -- BROWSER-PLAYABLE sovereign City-Building: BASE-RELATIVE integer core, runs native (-> PNG) AND in the browser (base = 0). NO float, NO JS logic, NO canvas drawing. CLICK a toolbar button to pick a building, CLICK the grid to place it (costs gold): farms make food, houses raise population capacity, and population grows when fed; markets make gold. Balance food vs houses vs markets to grow the city. Uses the click(x,y) export. init()/tick(input)/render()/score()/ww()/hh()/fb_off()/click(x,y) = the wasm interface. license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_nishi_font_core.nx nx_wasm_city.nx nx_wasm_city_gate.nx

imports: nx_nishi_font_core.nx

imported by: nx_wasm_city_gate.nx

structs

none

consts

8const W: i64 = 200
9const H: i64 = 170
10const GW: i64 = 10
11const GH: i64 = 7
12const CELL: i64 = 20
13const GY0: i64 = 24 // grid top (toolbar above)
14const TOOLH: i64 = 22
15const ECON: i64 = 30 // economy ticks
16const HCOST: i64 = 10
17const FCOST: i64 = 8
18const MCOST: i64 = 12
19const O_FB: i64 = 0 // framebuffer W*H i64
20const O_MAP: i64 = 272000 // map[GW*GH]: 0 empty,1 house,2 farm,3 market (W*H*8)
21const O_ST: i64 = 272560 // scalars[16]: 0=gold 1=food 2=pop 3=sel 4=tick 5=nhouse 6=nfarm 7=nmarket
22const O_MSK: i64 = 272688
23const O_STR: i64 = 280880

functions

25func rgb(r: i64, g: i64, b: i64) -> i64 { return (r & 255) | ((g & 255) << 8) | ((b & 255) << 16) }
called by 2: bcolorrender_impl
27func fillr(base: i64, x0: i64, y0: i64, x1: i64, y1: i64, c: i64) -> i64
called by 1: render_impl
39func bcolor(typ: i64) -> i64
called by 1: render_impl calls 1: rgb
44func bcost(typ: i64) -> i64 { if typ == 1 { return HCOST } if typ == 2 { return FCOST } return MCOST }
called by 1: click_impl
46func init_impl(base: i64) -> i64
called by 2: initmain
54func click_impl(base: i64, x: i64, y: i64) -> i64
called by 2: clickmain calls 1: bcost
73func tick_impl(base: i64, input: i64) -> i64
called by 2: tickrun
86func num(base: i64, x: i64, off: i64, val: i64, col: i64) -> i64
called by 1: render_impl calls 1: nf_draw_text_mem
100func render_impl(base: i64) -> i64
called by 2: rendermain calls 4: rgbfillrbcolornum
133func init() -> i64 { return init_impl(0) }
calls 1: init_impl
134func tick(input: i64) -> i64 { return tick_impl(0, input) }
calls 1: tick_impl
135func render() -> i64 { return render_impl(0) }
calls 1: render_impl
136func click(x: i64, y: i64) -> i64 { return click_impl(0, x, y) }
calls 1: click_impl
137func score() -> i64 { let st: *i64 = (0 + O_ST) as *i64; return st[2] }
138func fb_off() -> i64 { return O_FB }
139func ww() -> i64 { return W }
140func hh() -> i64 { return H }