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

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

w : Int

value · line 19
w ← "Voxels 6: endless -- X_eTaL" ˢᶜo̲pen! 640 400
Used in: g, _, s, ᵘf̲rame, z

g : Int

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

_ : Int

function · line 21
_ ← w ˢᶜs̲ky! 0.55 0.72 0.92

_ : Int

function · line 22
_ ← w ˢᶜc̲urve! 160.0

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))

value · line 28

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

s ← ᵉⁿn̲ew w
Used in: streamed

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))

value · line 29
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))

function · line 35

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

ᵘ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))

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

last : ((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))

value · line 46
last ← 100000 'ᵘf̲rame p̲ower streamed

z : Int

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