code wiki / _hdl_build / nx_gx7_game_gate.nx
nx_gx7_game_gate.nx
buildroot/runtime/_hdl_build/nx_gx7_game_gate.nx
about
nx_gx7_game_gate.nx -- Gx-7: the first playable becomes an actual GAME. The walk gate proved locomotion;
this adds the three things that make it a game rather than a camera demo: ENTITIES that exist in world
state, COLLISION that changes that state, and a WIN CONDITION the player can actually reach.
The full loop, every tick: input -> player state -> COLLISION RESOLVE (world state mutates) -> build the
player-relative mesh (terrain bands + only the entities still alive) -> nx_swgpu -> HUD overlay -> canvas
blit -> live browser repaint. The render is a PURE FUNCTION of game state, so "it vanished when I picked it
up" is a rendering fact, not a separate animation to keep in sync. Still DETERMINISTIC end to end: the same
script replays to byte-identical frames INCLUDING the collision outcomes.
license_tier: ORIGINAL expect_exit: 0
dependencies 3 imports · 0 importers
imports: nx_browser_render.nxnx_game_world.nxnx_frame_sanity.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 14 | const G7_STEP: i64 = 8192 // forward step = 2 cells |
| 15 | const G7_TURN: i64 = 3217 // ~45 degrees, rad*4096 |
| 16 | const G7_TICKS: i64 = 14 |
| 17 | const G7_N: i64 = 5 // beacons |
| 18 | const G7_PICKR: i64 = 4915 // pickup radius = 1.2 cells (fx4096) |
| 19 | const G7_EYE: i64 = 6600 // eye height above local ground (1.6 world units) |
| 20 | const G7_HUD_H: i64 = 24 // HUD strip height, excluded from beacon pixel measurement |
functions
| 22 | func g7_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 23 | func g7_pn(v: i64) -> i64 { let b: *u8=sys_mmap(32) as *u8; var x: i64=v; var ng: i64=0; if x<0{ng=1;x=0-x} var i: i64=31; if x==0{b[i]=48 as u8;i=i-1} while x>0{b[i]=(48+x%10) as u8;x=x/10;i=i-1} if ng==1{b[i]=45 as u8;i=i-1} sys_write(1,(b as i64+i+1) as *u8,31-i); return 0 } |
| 24 | func g7_now_ms() -> i64 { let ts: *i64=sys_mmap(16) as *i64; sys_clock_gettime_mono(ts); return ts[0]*1000 + ts[1]/1000000 } |
| 27 | func g7_hud(dst: *u8, collected: i64, won: i64) -> i64 called by 1: g7_run |
| 57 | func g7_render(base: i64, ex: *i64, ez: *i64, alive: *i64, ppx: i64, ppz: i64, yaw: i64, pitch: i64, eyey: i64, dst: *u8) -> i64 called by 1: g7_run calls 7: gw_build_terrainsg_project_clip_pitchsg_rendersg_render_passgw_build_entitiessg_ssao+1 |
| 89 | func g7_gold(dst: *u8) -> i64 called by 1: main |
| 108 | func g7_run(base: i64, fbuf: *u8, hist: *i64) -> i64 |
| 175 | func main() -> i64 |