code wiki / (root) / nx_wasm_pong.nx

nx_wasm_pong.nx

buildroot/runtime/nx_wasm_pong.nx

4933 B103 linesdepth 1pulls 1 transitivereach 1 importersview sourcekind librarytopic wasm
docsdependenciesstructsconstsfunctions

about

nx_wasm_pong.nx -- BROWSER-PLAYABLE sovereign Pong (Sport): BASE-RELATIVE integer core, runs native (-> PNG) AND in the browser (base = 0). NO float, NO JS logic, NO canvas drawing. You are the LEFT paddle (up/down); a beatable AI controls the right. The ball bounces off walls + paddles with SPIN (where it hits the paddle sets its vertical speed -> skill), and the AI tracks slower than max spin so you can score. Endless, scores climb. init()/tick(input)/render()/score()/ww()/hh()/fb_off() = the wasm interface. license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_nishi_font_core.nx nx_wasm_pong.nx nx_wasm_pong_gate.nx

imports: nx_nishi_font_core.nx

imported by: nx_wasm_pong_gate.nx

structs

none

consts

7const W: i64 = 200
8const H: i64 = 120
9const PADH: i64 = 16 // paddle half-height
10const LX: i64 = 8
11const RX: i64 = 192
12const O_FB: i64 = 0 // framebuffer W*H i64
13const O_ST: i64 = 192000 // scalars[16]: 0=bx 1=by 2=bvx 3=bvy 4=lpy 5=rpy 6=lscore 7=rscore
14const O_MSK: i64 = 192128 // HUD glyph scratch
15const O_STR: i64 = 200320 // HUD string scratch (left score @ +0, right score @ +32)

functions

17func rgb(r: i64, g: i64, b: i64) -> i64 { return (r & 255) | ((g & 255) << 8) | ((b & 255) << 16) }
called by 2: draw_numrender_impl
18func clampi(v: i64, lo: i64, hi: i64) -> i64 { if v < lo { return lo } if v > hi { return hi } return v }
called by 1: tick_impl
20func fillr(base: i64, x0: i64, y0: i64, x1: i64, y1: i64, c: i64) -> i64
called by 1: render_impl
33func serve(base: i64, dir: i64) -> i64
called by 2: init_impltick_impl
38func init_impl(base: i64) -> i64
called by 2: initmain calls 1: serve
45func tick_impl(base: i64, input: i64) -> i64
called by 2: tickmain calls 2: clampiserve
64func draw_num(base: i64, x: i64, off: i64, val: i64) -> i64
called by 1: render_impl calls 2: nf_draw_text_memrgb
82func render_impl(base: i64) -> i64
called by 2: rendermain calls 3: rgbfillrdraw_num
97func init() -> i64 { return init_impl(0) }
calls 1: init_impl
98func tick(input: i64) -> i64 { return tick_impl(0, input) }
calls 1: tick_impl
99func render() -> i64 { return render_impl(0) }
calls 1: render_impl
100func score() -> i64 { let st: *i64 = (0 + O_ST) as *i64; return st[6] }
101func fb_off() -> i64 { return O_FB }
102func ww() -> i64 { return W }
103func hh() -> i64 { return H }