Moles: A Year of Engine Evolution
Moles has come a long way since my first post in 2022. What started as a simple showcase for my ECS game engine has grown into a polished little game with proper state management, sound effects, difficulty progression, and satisfying visual feedback.
Direct link to game: >>> Play Moles! <<<
What’s New
Progressive Difficulty - The game now features 10 levels of increasing challenge. Each level ramps up the initial mole count, spawn rate, and threshold before you lose. Beat all the moles to advance to the next level.
Sound Effects - Using the zzfx library, Moles now has satisfying hit and miss sounds. The sounds are procedurally generated and embedded directly in the code - no audio files needed.
Visual Polish - Moles now shake randomly before being hit, giving a “whack-a-mole” feel. When you successfully hit a mole, there’s a squash effect and the mole flies off the screen with a smooth arc animation.
State System - The engine now has a proper declarative state management system. Moles uses this for the welcome screen, gameplay, win/lose conditions, and automatic transitions between levels.
Level Indicators - A flickering level indicator appears at the start of each round so you know how far you’ve progressed.
Technical Details
The entire game - sprites, sounds, tilemap, and all game logic - compiles down to a single 46KB HTML file. No external dependencies, no loading screens, instant playability.
The engine includes a debug system that shows FPS, entity count, and CPU time spent in each system - useful for profiling and optimization.
The core engine features used in Moles:
- TouchSystem - Handles click/tap input with configurable hit margins
- ShakeSystem - Adds the random jitter effect to moles
- BounceSystem - Used for the bouncing “Click to start” text
- SpriteSystem - Renders moles from a tilesheet
- FontSystem - Bitmap font rendering for score and messages
- SoundSystem - Pre-renders zzfx sounds at load time for instant playback
- StateSystem - Manages game states with automatic entity cleanup and system enable/disable
- RemoveSystem - Handles timed entity removal
The SpelagonECS Engine
This game is built on SpelagonECS, my custom TypeScript Entity Component System engine. The design goals are:
- Tiny bundle size - Everything in a single inlined HTML file
- No dependencies - Zero runtime npm packages
- Mobile-first - Touch input and mobile performance prioritized
- Multiple instances - Can run several games on the same page
The engine has grown to support tile maps, sprite animations, hierarchical transforms, particle effects, and more. Check out my other games built with the same engine!