
Personal Project
Space Invaders Game Engine
Overview
A playable Space Invaders clone developed in C# on top of the Azul game framework. The project was built as an architecture-focused real-time systems case study, with select/play/game-over scenes, credits, one- and two-player sessions, score tracking, waves, UFO events, destructible shields, animated aliens, and multiple bomb behaviors.
Role
Sole Engineer
Problem
A real-time arcade game has to update input, animation, collision, scoring, object removal, audio, and rendering every frame without turning the main loop into a tightly coupled script. Naive allocation and direct mutation during collision traversal can also create frame instability, garbage collection pressure, and hard-to-reproduce bugs.
Solution
Built a scene-driven engine around pool-backed manager classes, composite game-object trees, and event-style collision reactions. Visitor handles double-dispatch collision routing, Observer keeps reactions decoupled from detection, Command powers delayed events such as alien motion, bomb drops, UFO spawns, respawns, and scene changes, and Strategy gives bombs interchangeable fall behavior.
Architecture
The game runs through an Azul.Game lifecycle with centralized content loading, a SceneContext state machine, singleton resource managers, active/reserve object pools, sprite proxies, batched rendering, and a sorted timer-event list for scheduled gameplay commands.
Key Design Decisions
- SceneContext switches between Select, Play, and Game Over states while SessionManager preserves credits, active player, lives, high score, and one/two-player turn state.
- ManBase provides a reusable active/reserve-list template used by managers for textures, images, fonts, glyphs, sprites, collision pairs, game-object nodes, timers, sounds, and ghosted objects.
- Composite hierarchies model the AlienGrid, alien columns, shield grids, shield columns, walls, bumpers, missile group, bomb root, ship root, and UFO root as trees that can update and collide at multiple levels.
- ColPairMan registers collision pairs between object trees; ColRect performs rectangle intersection tests; Visitor resolves concrete runtime types; ColSubject then notifies focused observers for scoring, removal, sound, explosions, and state transitions.
- TimerEventMan stores Command objects on a sorted DLinkMan list and drives repeating alien animation, grid movement, randomized bomb drops, UFO spawning, delayed explosions, ship respawns, player swaps, and scene transitions.
- SpriteGameProxy, SpriteBoxProxy, SpriteGameBatch, TextureMan, and ImageMan share immutable sprite/image resources while allowing each live game object to maintain independent position and collision state.
Challenges
- Preventing collision observers from mutating the same composite tree being traversed, solved with mark-for-death flags plus DelayedObjectMan for deferred removals.
- Keeping two-player state consistent across scene transitions, respawns, player swaps, credits, lives, scores, preserved alien grids, and preserved shield damage.
- Modeling destructible shields as many tiny bricks without hardcoding every interaction between missiles, bombs, aliens, columns, and shield roots.
- Coordinating timer events across scene entry/exit and pause-like transitions so scheduled commands do not fire at stale times.
- Preloading and routing IrrKlang sound sources through SoundMan so explosions, missile shots, UFO audio, and alien movement sounds remain responsive during frame updates.
Impact
- Delivered a complete playable arcade clone with attract/select flow, credits, one/two-player mode, scoring, lives, waves, UFOs, destructible shields, alien acceleration, and varied bomb patterns.
- Reduced per-frame allocation pressure through reusable managers, reserve lists, sprite proxies, and delayed object recycling, making runtime behavior more predictable for a real-time game loop.
- Produced an engineering design document and UML diagrams covering 14 applied patterns: Singleton, Object Pool, Factory, Observer, Flyweight, Proxy, Command, Iterator, State, Composite, Strategy, Visitor, Null Object, Adapter, and Template Method.