blob: 11b6756e7df82a0b1b544070e0009a92eceb90c9 (
plain)
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
35
36
|
# Hold Space to charge a jump; gravity and the floor are authored here.
state holding = false
state charge = 0
state y = 240
state velocity = 0
input jump = key Space
view actor_y = y
view meter_width = charge * 200
view amount = charge
on jump.down {
if y >= 240 {
holding = true
charge = 0
}
}
on jump.up {
if holding {
velocity = -(160 + charge * 300)
holding = false
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
}
}
|