Mega Peggle is a comprehensive iOS clone of the classic game Peggle, built entirely from the ground up using Swift and SwiftUI. This project was built without any game engines (like Unity or Unreal) or boilerplate code.
The core of the application is a custom-built 2D physics engine, handling complex collisions for rotated blocks, gravity simulations, and trajectory predictions.
- PlatformiOS (iPad & iPhone)
- StackSwift, SwiftUI
- EngineCustom In-House Physics Engine
Full Gameplay Demo
Key Features
- Level DesignerA full-featured editor supporting real-time peg rotation and resizing. Includes live validation to prevent overlaps.
- Power-Up SystemAdvanced mechanics including the Aim Power-Up (trajectory preview with up to 3 bounce segments), Spooky Ball (teleportation/respawn logic), and Ka-Boom (explosive blast radius).
- Audio SystemIntegrated `AudioManager` with BGM crossfading, velocity-sensitive SFX, and distinct tracks for menu, designer, and gameplay.
- HUD & ScoringReal-time peg counters and a live scoring system based on peg type and multipliers.
Technical Insights
The architecture focuses on high decoupling and maintainability:
- Adapter Pattern: The View layer consumes `GameBodySnapshot` objects, ensuring the rendering logic is completely decoupled from the underlying `PhysicsEngine`.
- Stateless Simulation: Trajectory prediction was implemented by building a separate simulator that reuses the core physics math without affecting the active game world state.
- Abstraction Layer: Introduced `PhysicsBodyState` as an intermediary value type, allowing the physics implementation to be swapped or updated without affecting game rules.