nx_wasm_city.nx
buildroot/runtime/nx_wasm_city.nx
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
imports: nx_nishi_font_core.nx
imported by: nx_wasm_city_gate.nx
structs
| none |
consts
| 8 | const W: i64 = 200 |
| 9 | const H: i64 = 170 |
| 10 | const GW: i64 = 10 |
| 11 | const GH: i64 = 7 |
| 12 | const CELL: i64 = 20 |
| 13 | const GY0: i64 = 24 // grid top (toolbar above) |
| 14 | const TOOLH: i64 = 22 |
| 15 | const ECON: i64 = 30 // economy ticks |
| 16 | const HCOST: i64 = 10 |
| 17 | const FCOST: i64 = 8 |
| 18 | const MCOST: i64 = 12 |
| 19 | const O_FB: i64 = 0 // framebuffer W*H i64 |
| 20 | const O_MAP: i64 = 272000 // map[GW*GH]: 0 empty,1 house,2 farm,3 market (W*H*8) |
| 21 | const O_ST: i64 = 272560 // scalars[16]: 0=gold 1=food 2=pop 3=sel 4=tick 5=nhouse 6=nfarm 7=nmarket |
| 22 | const O_MSK: i64 = 272688 |
| 23 | const O_STR: i64 = 280880 |
functions
| 25 | func rgb(r: i64, g: i64, b: i64) -> i64 { return (r & 255) | ((g & 255) << 8) | ((b & 255) << 16) } |
| 27 | func fillr(base: i64, x0: i64, y0: i64, x1: i64, y1: i64, c: i64) -> i64 called by 1: render_impl |
| 39 | func bcolor(typ: i64) -> i64 |
| 44 | func bcost(typ: i64) -> i64 { if typ == 1 { return HCOST } if typ == 2 { return FCOST } return MCOST } called by 1: click_impl |
| 46 | func init_impl(base: i64) -> i64 |
| 54 | func click_impl(base: i64, x: i64, y: i64) -> i64 |
| 73 | func tick_impl(base: i64, input: i64) -> i64 |
| 86 | func num(base: i64, x: i64, off: i64, val: i64, col: i64) -> i64 |
| 100 | func render_impl(base: i64) -> i64 |
| 133 | func init() -> i64 { return init_impl(0) } calls 1: init_impl |
| 134 | func tick(input: i64) -> i64 { return tick_impl(0, input) } calls 1: tick_impl |
| 135 | func render() -> i64 { return render_impl(0) } calls 1: render_impl |
| 136 | func click(x: i64, y: i64) -> i64 { return click_impl(0, x, y) } calls 1: click_impl |
| 137 | func score() -> i64 { let st: *i64 = (0 + O_ST) as *i64; return st[2] } |
| 138 | func fb_off() -> i64 { return O_FB } |
| 139 | func ww() -> i64 { return W } |
| 140 | func hh() -> i64 { return H } |