diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/charge.aup | 36 | ||||
| -rw-r--r-- | examples/counter.aup | 9 | ||||
| -rw-r--r-- | examples/steps.aup | 24 | ||||
| -rw-r--r-- | examples/toggle.aup | 20 |
4 files changed, 89 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 + } +} diff --git a/examples/counter.aup b/examples/counter.aup new file mode 100644 index 0000000..d966292 --- /dev/null +++ b/examples/counter.aup @@ -0,0 +1,9 @@ +# Space increments a count; views expose what a surface would show. +state count = 0 +input tap = key Space +view label = count +view tile_width = 40 + min(count, 20) * 8 + +on tap.down { + count = count + 1 +} diff --git a/examples/steps.aup b/examples/steps.aup new file mode 100644 index 0000000..ee4eb47 --- /dev/null +++ b/examples/steps.aup @@ -0,0 +1,24 @@ +# if / else and else if; the first matching branch runs. +state level = 0 +state band = 0 +input up = key ArrowUp +input down = key ArrowDown +view shown = band + +on up.down { + level = level + 1 +} + +on down.down { + level = level - 1 +} + +on frame { + if level > 2 { + band = 2 + } else if level > 0 { + band = 1 + } else { + band = 0 + } +} diff --git a/examples/toggle.aup b/examples/toggle.aup new file mode 100644 index 0000000..39417cc --- /dev/null +++ b/examples/toggle.aup @@ -0,0 +1,20 @@ +# Space toggles visibility; Right arrow moves a position that wraps. +state visible = 1 +state position = 120 +input toggle = key Space +input move = key ArrowRight +view marker_x = position +view marker_radius = visible * 24 +view tile_x = position - 24 +view value = visible + +on toggle.down { + visible = !visible +} + +on move.down { + position = position + 40 + if position > 560 { + position = 80 + } +} |
