1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# All holding, charging, gravity, jumping, and floor behavior is authored here.
state holding = 0
state charge = 0
state y = 240
state velocity = 0
input jump = Space
box floor(40, 261, 560, 4, "#356548")
circle actor(180, y, 20, "#c78638")
box meter(80, 80, charge * 200, 12, "#c78638")
text amount(80, 60, charge, "Charge: ")
on jump.down {
if y >= 240 {
holding = 1
charge = 0
}
}
on jump.up {
if holding {
velocity = -(160 + charge * 300)
holding = 0
charge = 0
}
}
on frame {
if holding {
charge = clamp(charge + dt, 0, 1)
}
velocity = velocity + 600 * dt
y = y + velocity * dt
if y >= 240 {
y = 240
velocity = 0
}
}
|