sourceextensions/scene/demos/voxels-fly.xtl

1⍝│ Voxels, 7: flying. The endless world of voxels-endless, now from the 2⍝│ air: F switches between walking and flying. Flying moves level 3⍝│ whatever you look at -- W forward, S back, A and D sideways -- Space 4⍝│ rises and Shift sinks, with no gravity, the blocks still stopping you; 5⍝│ so you can look down at the land as you cross it. F again drops you 6⍝│ back to walking wherever you are. The columns are made ahead, one a 7⍝│ frame, and dropped behind, under fog and a curved horizon. 8⍝│ Run: just demo scene voxels-fly 9⍝│ F fly or walk; flying: W A S D level, Space up, Shift down; walking: 10⍝│ Space jump or swim up, Shift run; drag the mouse or the arrows to 11⍝│ look, H: back to the start, q quit 12 13"en:" u̲se< "Endless" 14"sc:" u̲se< "Scene" 15 16w ← "Voxels 7: flying -- X_eTaL" ˢᶜo̲pen! 640 400 17g ← w ˢᶜf̲og! 22.0 44.0 18_ ← w ˢᶜs̲ky! 0.55 0.72 0.92 19_ ← w ˢᶜc̲urve! 160.0 20 21"keys: F fly or walk; flying: W A S D level, Space up, Shift down; walking: Space jump/swim, Shift run; drag or arrows look; H home; q quit" 22 23⍝│ the world around the start made before the first frame: each column 24⍝│ takes three steps 25s ← ᵉⁿn̲ew w 26streamed ← (3 × (1 + 2 × ᵉⁿreach) × 1 + 2 × ᵉⁿreach) 'ᵉⁿs̲tream p̲ower s 27"columns made at the start:" 28t̲ally ᵉⁿk̲eys streamed 29 30⍝│ one frame: an event, then a third of a column's work, then the 31⍝│ player 32ᵘf̲rame ← { s → 33 ᵉⁿs̲topped s ? s 34 v ← ˢᶜn̲ext! w 35 ((v m̲atch "close") + (v m̲atch "key q") + v m̲atch "key Escape") > 0 ? ᵉⁿs̲top s 36 stepped ← (v m̲atch "key f") ᵘf̲ly ᵉⁿs̲tream (v m̲atch "key h") ᵘi̲f s 37 stepped ᵉⁿm̲ove ˢᶜc̲ontrols w 38} 39ᵘi̲f ← { yes s → 40 yes ? ᵉⁿh̲omeAgain s 41 s 42} 43ᵘf̲ly ← { yes s → 44 yes ? ᵉⁿt̲oggleFly s 45 s 46} 47last ← 100000 'ᵘf̲rame p̲ower streamed 48z ← ˢᶜc̲lose! w 49"where it ended (x y z, blocks), the columns kept:" 50(f̲loat f̲loor 0.5 + ᵉⁿp̲osition last) c̲at f̲loat t̲ally ᵉⁿk̲eys last 51"bye"