aboutsummaryrefslogtreecommitdiffstats
path: root/examples/charge.aup
blob: d483b8f24f0648c688cdabe6c559ccf2b910bd86 (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 = 0
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 = 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
  }
}