diff options
| author | eunhhu <[email protected]> | 2026-09-25 11:05:51 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-25 11:05:51 +0100 |
| commit | 3e35975ee9120042baa0e8fe2bb2d52311204e84 (patch) | |
| tree | c56902403251c964f493e69df7e343167e981a81 /examples | |
| parent | e058795152fdb678aa71b67acd7a0fb44dabe747 (diff) | |
| download | aup-3e35975ee9120042baa0e8fe2bb2d52311204e84.tar.gz aup-3e35975ee9120042baa0e8fe2bb2d52311204e84.zip | |
Compile v0a programs to verified Pure modules
aup check/build parse states, key inputs, views and handlers (with if/else
and else-if), resolve names, generate forward-only stack code and encode a
Pure module v1 deterministically. Diagnostics carry file:line:column.
make check loads every module with Pure's verifier, checks determinism, 20
diagnostics and accepted forms, replacement by name, 600 generated programs
and damaged sources (every emitted module verifies), and replays random event
scripts against the workbench Zig engine: 16,667 snapshots across counter,
toggle, charge, else-if and fault programs matched, including 921 failed
events. The sanitizer-built compiler passes the same checks.
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 + } +} |
