programgames/scroller/scroller.xtl

The side-scroller, scripted (seed 1), with the rules of Jump.xtl on lib/Ecs: the world as a matrix, and gravity, movement and collision as systems over every body at once.

source · imports j: games/scroller/Jump.xtl; ec: lib/Ecs.xtl lib/Ecs.xtlm

start : (Float, Int, Float, Int)

value · line 12
start ← ʲn̲ew 0

W : Float

value · line 13
(W, g, t, st) ← start

g : Int

value · line 13
(W, g, t, st) ← start
Used in: W

t : Float

value · line 13
(W, g, t, st) ← start
Used in: W

st : Int

value · line 13
(W, g, t, st) ← start
Used in: W

ᵘr̲un : (Num a, Num b) => (Float, Int, Float, a) -> b -> (Float, Int, Float, a)

function · line 26
ᵘr̲un ← { s n → n = 0 ? s◆ ((s ʲk̲ey "RIGHT") ʲt̲ick 0.05) ᵘr̲un n − 1 }
Used in: ᵘr̲un, ran

ran : (Float, Int, Float, Int)

value · line 27
ran ← start ᵘr̲un 10

ᵘh̲eight : (Num a, Any b) => (Float, a, Float, b) -> Float

function · line 32
ᵘh̲eight ← { s → 2 s̲elect ʲy̲ou s }
Used in: ᵘa̲ir

ᵘa̲ir : (Num a, Num b) => (Float, Int, Float, a) -> b -> Float

function · line 33
ᵘa̲ir ← { s n → n = 0 ? 0 r̲eshape 0.0◆ (ᵘh̲eight s) c̲at (s ʲt̲ick 0.05) ᵘa̲ir n − 1 }
Used in: ᵘa̲ir, y

up : (Float, Int, Float, Int)

value · line 34
up ← ran ʲk̲ey "UP"
Used in: y, _

y : Float

value · line 35
y ← up ᵘa̲ir 16

_ : Char

function · line 37
_ ← ⎕S̲HOW ʲd̲raw up

_ : Unit

function · line 40
_ ← "1 = f_irst j:c_ounts j:n_ew 0" a̲ssert< "one of you in a new game"
a̲ssert< expands to
({ @ → (1 = f̲irst ʲc̲ounts ʲn̲ew 0) ? @◆ ⎕E̲RR "assertion failed: 1 = f_irst j:c_ounts j:n_ew 0 (one of you in a new game) [games/scroller/scroller.xtl:40]"◆ @ } @)

_ : Unit

function · line 41
_ ← "(f_irst y) = 'm_ax r_/ y" a̲ssert< "a jump goes up and comes back down to where it started"
a̲ssert< expands to
({ @ → ((f̲irst y) = 'm̲ax r̲/ y) ? @◆ ⎕E̲RR "assertion failed: (f_irst y) = 'm_ax r_/ y (a jump goes up and comes back down to where it started) [games/scroller/scroller.xtl:41]"◆ @ } @)

_ : Unit

function · line 42
_ ← "0 = j:s_tatus up" a̲ssert< "still playing"
a̲ssert< expands to
({ @ → (0 = ʲs̲tatus up) ? @◆ ⎕E̲RR "assertion failed: 0 = j:s_tatus up (still playing) [games/scroller/scroller.xtl:42]"◆ @ } @)