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 : ((Float, Float, Float, Float, Float, Float), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (Int, Int, Int, Int), (Int, Int, Float, Int, Int))
the world around the start made before the first frame: each column takes three steps
s ← ᵉⁿn̲ew w
streamed : ((Float, Float, Float, Float, Float, Float), (Int, Int, Box Int, Box Int, Int, Int, Int, Int), (Int, Int, Int, Int), (Int, Int, Float, Int, Int))
streamed ← (3 × (1 + 2 × ᵉⁿreach) × 1 + 2 × ᵉⁿreach) 'ᵉⁿs̲tream p̲ower s
ᵘf̲rame : (Num a, Num b, Num c, Num d) => ((Float, Float, Float, Float, Float, Float), (Int, Int, Box Int, Box Int, Int, Int, Int, a), (b, Int, Int, Int), (Int, Int, Float, c, d)) -> ((Float, Float, Float, Float, Float, Float), (Int, Int, Box Int, Box Int, Int, Int, Int, a), (b, Int, Int, Int), (Int, Int, Float, c, d))
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 stepped ← ᵉⁿs̲tream (v m̲atch "key h") ᵘi̲f s stepped ᵉⁿm̲ove ˢᶜc̲ontrols w }
ᵘi̲f : (Truthy a, Num b, Num c, Num d, Num e) => a -> ((Float, Float, Float, Float, Float, Float), (Int, Int, Box Int, Box Int, Int, Int, Int, b), (c, Int, Int, Int), (Int, Int, Float, d, e)) -> ((Float, Float, Float, Float, Float, Float), (Int, Int, Box Int, Box Int, Int, Int, Int, b), (c, Int, Int, Int), (Int, Int, Float, d, e))
ᵘi̲f ← { yes s → yes ? ᵉⁿh̲omeAgain s s }