nx_wasm_pong.nx
buildroot/runtime/nx_wasm_pong.nx
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
imports: nx_nishi_font_core.nx
imported by: nx_wasm_pong_gate.nx
structs
| none |
consts
| 7 | const W: i64 = 200 |
| 8 | const H: i64 = 120 |
| 9 | const PADH: i64 = 16 // paddle half-height |
| 10 | const LX: i64 = 8 |
| 11 | const RX: i64 = 192 |
| 12 | const O_FB: i64 = 0 // framebuffer W*H i64 |
| 13 | const O_ST: i64 = 192000 // scalars[16]: 0=bx 1=by 2=bvx 3=bvy 4=lpy 5=rpy 6=lscore 7=rscore |
| 14 | const O_MSK: i64 = 192128 // HUD glyph scratch |
| 15 | const O_STR: i64 = 200320 // HUD string scratch (left score @ +0, right score @ +32) |
functions
| 17 | func rgb(r: i64, g: i64, b: i64) -> i64 { return (r & 255) | ((g & 255) << 8) | ((b & 255) << 16) } |
| 18 | func 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 |
| 20 | func fillr(base: i64, x0: i64, y0: i64, x1: i64, y1: i64, c: i64) -> i64 called by 1: render_impl |
| 33 | func serve(base: i64, dir: i64) -> i64 |
| 38 | func init_impl(base: i64) -> i64 |
| 45 | func tick_impl(base: i64, input: i64) -> i64 |
| 64 | func draw_num(base: i64, x: i64, off: i64, val: i64) -> i64 |
| 82 | func render_impl(base: i64) -> i64 |
| 97 | func init() -> i64 { return init_impl(0) } calls 1: init_impl |
| 98 | func tick(input: i64) -> i64 { return tick_impl(0, input) } calls 1: tick_impl |
| 99 | func render() -> i64 { return render_impl(0) } calls 1: render_impl |
| 100 | func score() -> i64 { let st: *i64 = (0 + O_ST) as *i64; return st[6] } |
| 101 | func fb_off() -> i64 { return O_FB } |
| 102 | func ww() -> i64 { return W } |
| 103 | func hh() -> i64 { return H } |