code wiki / (root) / nx_day_night_cycle.nx

nx_day_night_cycle.nx

buildroot/runtime/nx_day_night_cycle.nx

8044 B189 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_day_night_cycle.nx -- diurnal lighting + sun position model. Per honest gap roadmap 2026-05-16: world needs a day/night loop so gameplay has dawn/dusk dramatic moments, hostile mobs spawn at night, and atmosphere primitives have meaningful sun position to drive sky color. MODEL: - 1 game day = N ticks (caller-configurable; default 24000 ticks for Minecraft-compatible 20 minutes at 20 tps). - Sub-phases: * DAWN ticks [0, day/8) sun rising; sky reddening * MORNING ticks [day/8, day*3/8) sun climbing * NOON ticks [day*3/8, day*5/8) sun overhead * AFTERNOON ticks [day*5/8, day*7/8) sun descending * DUSK ticks [day*7/8, day*9/16) sun setting; sky reddening * NIGHT ticks [day*9/16, day) moon up; hostile spawn enabled (Actually for simplicity: day_frac in [0, Q]; mid-day = Q/2; midnight = 0 / Q. Sub-phases inferred from day_frac.) PUBLIC APIs: nx_day_frac_q14(tick, ticks_per_day) -> Q14 [0, Q] nx_sun_zenith_q14(day_frac) -> Q14 (0 = overhead, Q = horizon) nx_ambient_light_q14(day_frac) -> Q14 [0, Q] nx_phase(day_frac) -> NX_PHASE_* nx_is_night(day_frac) -> 0/1 genealogy_id: solar_day_canon + minecraft_day_night lineage_id: nx_day_night_cycle_q14_v1

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_tier.nx nx_day_night_cycle.nx

imports: nx_syscalls.nxnx_tier.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_day_frac_q14 nx_phase nx_is_night nx_phase ↻ nx_sun_zenith_q14 nx_ambient_light_q14 nx_sun_zenith_q14 ↻ nx_phase_is_valid

structs

none

consts

39const NX_MAGIC_24000: i64 = 24000
40const NX_MAGIC_12000: i64 = 12000
41const NX_MAGIC_48000: i64 = 48000
43const NX_DN_Q: nx_int = 16384
46const NX_PHASE_DAWN: nx_int = 0
47const NX_PHASE_MORNING: nx_int = 1
48const NX_PHASE_NOON: nx_int = 2
49const NX_PHASE_AFTERNOON: nx_int = 3
50const NX_PHASE_DUSK: nx_int = 4
51const NX_PHASE_NIGHT: nx_int = 5
52const NX_PHASE_COUNT: nx_int = 6
61const NX_DN_DEFAULT_TICKS_PER_DAY: nx_int = 24000

functions

54func nx_phase_is_valid(p: nx_int) -> nx_int
called by 1: main
66func nx_day_frac_q14(tick: nx_int, ticks_per_day: nx_int) -> nx_int
called by 1: main
83func nx_phase(day_frac_q14: nx_int) -> nx_int
called by 2: nx_is_nightmain
95func nx_is_night(day_frac_q14: nx_int) -> nx_int
called by 1: main calls 1: nx_phase
112func nx_sun_zenith_q14(day_frac_q14: nx_int) -> nx_int
135func nx_ambient_light_q14(day_frac_q14: nx_int) -> nx_int
called by 1: main calls 1: nx_sun_zenith_q14
147func main() -> i64