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

source · imports en: extensions/scene/demos/Endless.xtl; sc: extensions/scene/lib/Scene.xtl

w : Int

value · line 16
w ← "Voxels 7: flying -- X_eTaL" ˢᶜo̲pen! 640 400
Used in: g, k, s, ᵘf̲rame, z

g : Int

value · line 17
g ← w ˢᶜf̲og! 22.0 44.0

k : Int

value · line 18
k ← w ˢᶜs̲ky! 0.55 0.72 0.92

k : Int

value · line 19
k ← w ˢᶜc̲urve! 160.0

s : Box Float

value · line 25

the world around the start made before the first frame: each column takes three steps

s ← ᵉⁿn̲ew w

s : Box Float

value · line 26
s ← (3 × (1 + 2 × ᵉⁿreach) × 1 + 2 × ᵉⁿreach) 'ᵉⁿs̲tream p̲ower s

ᵘf̲rame : Box Float -> Box Float

function · line 32

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
}
Used in: last

ᵘi̲f : Truthy a => a -> Box Float -> Box Float

function · line 41
ᵘi̲f ← { yes s →
  yes ? ᵉⁿh̲omeAgain s
  s
}
Used in: ᵘf̲rame

ᵘf̲ly : Truthy a => a -> Box Float -> Box Float

function · line 45
ᵘf̲ly ← { yes s →
  yes ? ᵉⁿt̲oggleFly s
  s
}
Used in: ᵘf̲rame

last : Box Float

value · line 49
last ← 100000 'ᵘf̲rame p̲ower s

z : Int

value · line 50
z ← ˢᶜc̲lose! w