Decompose: Break down #22 into implementable work units #37

Closed
opened 2026-05-27 01:05:49 +00:00 by Mark · 2 comments
Owner

Assessment

Issue #22 requests physics engine integration for a marble maze game. Currently no physics at all.

Proposed Phases

P1: Physics engine selection & setup

Choose engine (Matter.js, Cannon.js, or similar). Set up the physics world, gravity, collision detection.

P2: Marble physics

Add rigid body for the marble: mass, friction, restitution. Handle rolling, tilting, and momentum.

P3: Maze obstacles & collision

Add physics bodies for maze walls, ramps, holes. Handle ball-wall interactions and triggers (e.g., falling into a hole resets position).

P4: Physics query API

Expose readouts: velocity, position, collision events. Wire to game logic (win conditions, scoring).

P5: Debug visualization

Optional overlay showing physics bodies, collision boxes, force vectors for development.

## Assessment Issue #22 requests physics engine integration for a marble maze game. Currently no physics at all. ## Proposed Phases ### P1: Physics engine selection & setup Choose engine (Matter.js, Cannon.js, or similar). Set up the physics world, gravity, collision detection. ### P2: Marble physics Add rigid body for the marble: mass, friction, restitution. Handle rolling, tilting, and momentum. ### P3: Maze obstacles & collision Add physics bodies for maze walls, ramps, holes. Handle ball-wall interactions and triggers (e.g., falling into a hole resets position). ### P4: Physics query API Expose readouts: velocity, position, collision events. Wire to game logic (win conditions, scoring). ### P5: Debug visualization Optional overlay showing physics bodies, collision boxes, force vectors for development.
Mark closed this issue 2026-05-27 01:21:40 +00:00
Author
Owner

Closed as completed. All 5 phases of this decomposition were already implemented via a custom physics engine (not Matter.js/Cannon.js as suggested, but functionally equivalent):

  • P1 — Custom engine in app/src/game/physics.ts: vec2 math (add/sub/mul/dot/normalize), circle-rect collision, line-circle intersection, physics constants (PHYS object)
  • P2 — updateMarblePhysics(): acceleration, friction, speed clamping (MAX_SPEED 8 / BOOST_MAX_SPEED 12), wall collision with bounce + tangential friction, rotation, ground detection, ice tile friction, frozen slowdown, invincibility timers, wallJump(), applyBoost()
  • P3 — updateObstacles() + checkObstacleCollision(): 9 obstacle types (spinner, boulder, moving platform, pendulum, collapsing platform, spikes, speedgate, magnetic, gravitywell), collision routing per type in engine.ts
  • P4 — Full API through Marble type (pos, vel, speed, rotation, grounded, touchingWall, wallNormal), exported collision/utility functions used by engine/renderer
  • P5 (Debug visualization) — Not implemented (optional). Could be filed as a separate enhancement.

Tests: physics.test.ts (721 lines), engine.test.ts (531 lines) — all passing.

**Closed as completed.** All 5 phases of this decomposition were already implemented via a custom physics engine (not Matter.js/Cannon.js as suggested, but functionally equivalent): - **P1** — Custom engine in `app/src/game/physics.ts`: vec2 math (add/sub/mul/dot/normalize), circle-rect collision, line-circle intersection, physics constants (PHYS object) - **P2** — `updateMarblePhysics()`: acceleration, friction, speed clamping (MAX_SPEED 8 / BOOST_MAX_SPEED 12), wall collision with bounce + tangential friction, rotation, ground detection, ice tile friction, frozen slowdown, invincibility timers, wallJump(), applyBoost() - **P3** — `updateObstacles()` + `checkObstacleCollision()`: 9 obstacle types (spinner, boulder, moving platform, pendulum, collapsing platform, spikes, speedgate, magnetic, gravitywell), collision routing per type in `engine.ts` - **P4** — Full API through `Marble` type (pos, vel, speed, rotation, grounded, touchingWall, wallNormal), exported collision/utility functions used by engine/renderer - **P5** (Debug visualization) — Not implemented (optional). Could be filed as a separate enhancement. Tests: `physics.test.ts` (721 lines), `engine.test.ts` (531 lines) — all passing.
Author
Owner

Fixed in commit. Closing.

Fixed in commit. Closing.
Sign in to join this conversation.
No description provided.