plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
32795d4
— Peter John
2026-11-16T14:42:42+05:30
docs/plans: declarative bodies
docs/plans/2026-11-13-std-game-review.md
CHANGED
|
@@ -43,3 +43,9 @@ Events stay the only source of truth; std keeps held state as a pure fold of the
|
|
|
43
43
|
Objects decide their own collisions (option A): `Meets<Other, A>` with `meets(self, other) -> Option<A>` on Orb (Caught(orb: id)) and Mine (Hit); `rules(self) -> List<A>` collects `..xs.filterMap(|x| x.meets(self.ship))`; `update` handles `Caught`; a counter-based `Random.at(seed:, tick:, salt:)` replaces threading `rng` (no Rolled/Caught accumulators, `deal` a plain map); `touches` in std from declared circle shapes; `Place` as a `Vec2` where that removes conversions. Option B (std contact search) not chosen.
|
|
44
44
|
- Revised (user 2026-11-16): no `Meets` trait; the screen's `rules` is a plain list literal: `..self.orbs.filter(|o| self.ship.touches(o)).map(|o| Caught(orb: o.id))` and `if self.ship.hurt <= 0.0 && self.mines.any(|m| self.ship.touches(m)) then Hit`.
|
|
45
45
|
- Done on `sl/rules` (user, mid-task: drop `Meets`, the checks stay in the screen's rules): `rules(self) -> List<PlayAction>` is `[..self.orbs.filter(|o| self.ship.touches(o)).map(|o| Caught(orb: o.id)), if self.ship.hurt <= 0.0 && self.mines.any(|m| self.ship.touches(m)) then Hit]`, the frame `Next(state: moved, then: if moved.over then Nil else moved.rules())`, `update`'s `Caught(orb)` scores and respawns that orb; `Random.at(seed, tick, salt)` with `intAt`/`floatAt`/`intBelowAt(i)` (SplitMix64's mix and stream; std/math/Random), the screens keep `seed` and `ticks` (Orbit Runner and Balloon Pop), `deal` and Balloon Pop's respawn are `map`s, `Rolled` (std's, still used by `nextInt`) and the games' `Caught`/`Spawned` accumulators gone from the games; `trait Round[View]` (std/game/Round: `radius()`, `touches(other: Round)` about `Place.pivot()`), the ship, orbs and mines `Round`; orbs have an `id` (their animation phase is `id * 0.1`). Orbit Runner's checksum 818414470 to 181767343; orbit update 12.0 to 11.8-12.3 ms, paint 130 to 130.5-131 ms (noise); in place: `PlayingScreen.rules` has no spread left (it returns actions), `Motion.spawn` gains one, the rest kept.
|
|
46
|
+
|
|
47
|
+
## Declarative bodies (user 2026-11-16: "Yes please do it"), after the benchmark, before the clockwork/menu games
|
|
48
|
+
- A std `Body(pos: Vec2, vel: Vec2 = Zero, push: Vec2 = Zero, drag = 0.0, bounds: Option<Rect> = None, stopAtEdges/bounceAtEdges, faceAbove: Option<Float>, ..)` with `step(dt)` written once (integrate, drag, clamp, stop/bounce, facing); actors declare properties instead of hand physics.
|
|
49
|
+
- `Vec2` fields (`vel`, `thrust`) instead of x/y pairs; vector operators.
|
|
50
|
+
- Timers as moments (`hurtUntil`, `hurt()` = `clock < hurtUntil`) instead of countdowns.
|
|
51
|
+
- The `[Steps]` derive steps a `Body` field (any steppable value, not only actors), so `Ship.step` only advances `clock`; Orb/Mine `Motion`/`drifted`/bounce become a `Body` with `bounceAtEdges`; Balloon Pop where it fits.
|