programextensions/scene/demos/voxels-endless.xtl
Voxels, 6: an endless world. Walk in any direction and it never ends: the land comes from value noise hashed from the coordinates (vx:h_eightsAt), so any column of 16 by 16 blocks can be made by itself and fits its neighbors; columns are made around the player as it walks -- the nearest missing one each frame -- and dropped behind it; fog hides the edge of what is made, and a curved horizon (scene lowers the world by d^2 / 2R) makes it look like a small planet. Collision asks the columns themselves. The world and the player are the library Endless.xtl, shared with voxels-fly: each column is made over three frames, so no frame waits long. Run: just demo scene voxels-endless W A S D walk, Shift run, Space jump (in water: swim up; at the surface: climb out onto a bank one block high), drag the mouse or the arrows to look, H: back to the start, q or close: quit
s : Box Float
the world around the start made before the first frame: each column takes three steps
s ← ᵉⁿn̲ew w
ᵘf̲rame : Box Float -> Box Float
one frame: an event, then a third of a column's work, then the player
ᵘf̲rame ← { s → ᵉⁿs̲topped s ? s v ← ˢᶜn̲ext! w ((v m̲atch "close") + (v m̲atch "key q") + v m̲atch "key Escape") > 0 ? ᵉⁿs̲top s s ← (v m̲atch "key h") ᵘi̲f s s ← ᵉⁿs̲tream s s ᵉⁿm̲ove ˢᶜc̲ontrols w }
ᵘi̲f : Truthy a => a -> Box Float -> Box Float
ᵘi̲f ← { yes s → yes ? ᵉⁿh̲omeAgain s s }