programextensions/scene/demos/voxels-fly.xtl
Voxels, 7: flying. The endless world of voxels-endless, now from the air: F switches between walking and flying. Flying moves level whatever you look at -- W forward, S back, A and D sideways -- Space rises and Shift sinks, with no gravity, the blocks still stopping you; so you can look down at the land as you cross it. F again drops you back to walking wherever you are. The columns are made ahead, one a frame, and dropped behind, under fog and a curved horizon. Run: just demo scene voxels-fly F fly or walk; flying: W A S D level, Space up, Shift down; walking: Space jump or swim up, Shift run; drag the mouse or the arrows to look, H: back to the start, q 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 ← (v m̲atch "key f") ᵘf̲ly 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 }
ᵘf̲ly : Truthy a => a -> Box Float -> Box Float
ᵘf̲ly ← { yes s → yes ? ᵉⁿt̲oggleFly s s }