aboutsummaryrefslogtreecommitdiffstats
path: root/examples/charge.aup
diff options
context:
space:
mode:
Diffstat (limited to 'examples/charge.aup')
-rw-r--r--examples/charge.aup36
1 files changed, 36 insertions, 0 deletions
diff --git a/examples/charge.aup b/examples/charge.aup
new file mode 100644
index 0000000..d483b8f
--- /dev/null
+++ b/examples/charge.aup
@@ -0,0 +1,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
+ }
+}