Back to Cannon Drop

Documentation

DELIVERABLES

Deliverables — Cannon Drop

Summary

Cannon Drop is a 2D physics puzzle game built with TypeScript, HTML5 Canvas, and Matter.js. The player aims a cannon, fires a ball through a field of pegs and obstacles, and scores by clearing orange pegs and landing in buckets.

What Was Built

  • Engine Module (cannon-drop-engine.ts) — Pure TypeScript module with all game logic, level data (5 levels), scoring, combo multipliers, star ratings, aim/launch mechanics, and game state management. Zero browser dependencies. Fully testable with Node.js.
  • HTML Game (cannon-drop.html) — Browser file with Matter.js physics, 4-layer Canvas rendering (background, objects, ball/FX, UI), procedural audio via Web Audio API, mouse/keyboard input, level select screen, HUD, and level complete overlays.
  • Build Pipeline — TypeScript compilation via tsc with HTML copy to dist/.
  • Test Suite — 155 programmatic tests covering all engine functions, level data, scoring, and edge cases.

Test Results (from node --test output)

shell
# tests 155
# suites 49
# pass 155
# fail 0
# cancelled 0
# skipped 0

Feature Coverage

Implemented (Must-Have)

RequirementFeatureStatus
FR-1Level Data System (5 levels, exact peg positions, bucket configs, obstacle counts)Done
FR-2Peg Base Values (orange=100, blue=25, green=500)Done
FR-3Combo Multiplier (tiered: 1/2/3/5/10)Done
FR-4Shot Score Calculation (delegates to getComboMultiplier)Done
FR-5Star Rating (0-3 stars, allPegsCleared override)Done
FR-6Aim and Launch (clampAngle, clampPower, calculateLaunchVelocity)Done
FR-7Game State Management (createGameState with getLevelData delegation)Done
FR-8Level Completion and Game OverDone
FR-9Slow-Motion TriggerDone
FR-10Ball Count and Green Peg BonusDone
FR-11Physics World Setup (Matter.js engine, bodies, collision detection)Done
FR-12Peg Collision and RemovalDone
FR-13Pivoting Platform PhysicsDone
FR-14Pipe and Chute ConstructionDone
FR-15Bumper PhysicsDone
FR-16Funnel PhysicsDone
FR-17Bucket Scoring DetectionDone
FR-18Moving Jackpot Bucket (Level 5 only)Done
FR-19Wall BoundariesDone
FR-20Multi-Layer Canvas Rendering (4 visible + 1 offscreen bloom)Done
FR-21Ball Rendering and Effects (gradients, glow, particles)Done
FR-22Peg Rendering and Hit AnimationsDone
FR-23Obstacle Rendering (platforms, pipes, bumpers, funnels, buckets)Done
FR-24Background and Atmosphere (gradient, bokeh, vignette)Done
FR-25Bloom/Glow Post-Processing (offscreen canvas)Done
FR-26Screen Effects (shake, slow motion, confetti)Done
FR-27Level Select Screen (frosted glass cards, lock icons, stars)Done
FR-28In-Game HUD (score, balls, orange count, combo)Done
FR-29Level Complete Overlay (stars, score, continue)Done
FR-30Aiming Interface (cannon rotation, trajectory, power meter)Done
FR-31Input Handling (mouse aim/fire, R reset, N next level)Done
FR-32Responsive Canvas Sizing (5:4 aspect, letterboxing)Done
FR-33Procedural Sound Effects (fire, peg hit, bumper, bucket, ball lost, level complete, green peg)Done
FR-34Ambient Audio and Volume ControlDone
FR-35TypeScript Build Pipeline (tsc + HTML copy)Done

Nice-to-Have Features

Implemented

  • FR-21: Motion trail particles while ball is moving
  • FR-22: Score popups with spring animation and color-matching
  • FR-25: Bloom canvas (offscreen at half resolution)
  • FR-26: Confetti on level complete (150 particles, 3-5 seconds)

Deferred

  • FR-21: Full ribbon motion trail with additive blending — simplified to particle sparks for performance
  • FR-25: Multi-pass box blur — bloom canvas exists but blur passes simplified
  • FR-33: Pipe rolling sound — deferred (continuous brown noise modulation complex to implement without distortion)
  • FR-33: Slow-mo audio filter sweep — deferred (low-pass sweep on all audio requires re-routing all nodes)

Project Layout

shell
3-development/
  src/
    cannon-drop-engine.ts     # TypeScript engine source
    cannon-drop.html          # Browser game file
  tests/
    cannon-drop-engine.test.js  # 155 tests
  dist/
    cannon-drop-engine.js     # Compiled JS engine
    cannon-drop-engine.d.ts   # Type declarations
    cannon-drop.html          # Copied HTML
  docs/
    README.md                 # Project documentation
    DELIVERABLES.md           # This file
    lint-output.txt           # TypeScript compiler output
  package.json
  tsconfig.json

Build & Run

bash
npm install          # Install matter-js + typescript
npm run build        # Compile TS + copy HTML to dist/
npm test             # Run 155 engine tests
npx http-server dist -p 8080  # Serve and play

Dependencies

  • matter-js 0.20.0 — Physics engine (runtime, loaded via CDN in HTML)
  • typescript 5.7.3 — TypeScript compiler (dev only)

© 2026 Jonathan Leahy · v0.8.1-31-g196fa14