Overview
The constraint: a whole game in C++ with no game engine and no GPU rendering. The first version, PixelFox, was a four-week build. It worked, but ran at 55–68 FPS with about 40 enemies at 1280×720 and no lighting, had race conditions between its logic and render threads, and its test suite never compiled. I rebuilt the PixelFox engine around a tile-based renderer, a job system and AVX2, and turned the prototype into a finished game: Vulpes Noctis, a dark-fantasy action adventure with combo combat, a skill tree, branching dialogue and a two-phase boss. Every number here was measured on one machine, a 16-core Ryzen 9 9950X. The art is the free Ninja Adventure pack (CC0) by Pixel-boy and AAA, and the music and sound effects are AI-generated.
What I built
The engine: PixelFox, about 5,100 lines of C++20
- Tile-based software renderer Sprites are binned into 64×40 screen tiles and each tile is drawn by one job, so a frame needs no locks and the output is identical on 1 or 16 threads, which a test checks.
- Lighting on the CPU Normal-mapped point lights, soft 2D shadows from polar shadow maps, emissive sprites, bloom, ACES tonemapping, colour grading, vignette, ordered dither and an optional CRT filter.
- AVX2 Blending and tonemapping in AVX2, chosen at run time by CPU detection, with a scalar fallback. On one thread it takes the tonemap, grade and dither pass from 4.9 to 1.85 ms (2.7×).
- Job system One worker per physical core, an atomic work counter, and spin-then-sleep between passes.
- Pipelined main loop The game ticks at a fixed 60 Hz while the previous frame renders on its own thread from a double-buffered draw list, with an exception-safe shutdown.
- Audio, input and tools My own software mixer on XAudio2 (pan, pitch, loop points, fades and buses; WAV and OGG), tick-latched input with XInput gamepads and rebindable actions, a crash reporter (stack trace and minidump), a session log, the F3 profiler and frame recording for trailers.
The game: Vulpes Noctis, about 5,200 lines on flecs (ECS)
- Combat A 3-hit combo with input buffering, a dash with i-frames, aimed spells, hit-stop and knockback.
- Enemies AI state machines with a BFS flow field for pathing, elites, and a two-phase boss.
- Progression and story A 15-skill tree, branching data-driven dialogue (36 nodes, 3 quests, 2 endings), a shop and potions.
- Saves Versioned save files written atomically, and shrine checkpoints.
Tests
- 181 Google Test cases Renderer determinism, AVX2 against scalar, the job system, input, the audio mixer, gameplay, save files, dialogue script integrity and a 3-minute soak test with the real renderer.
Results
| Threads | Frame, average | Slowest 1% | FPS |
|---|---|---|---|
| 1, scalar | 15.24 ms | 19.38 ms | 66 |
| 1, AVX2 | 12.42 ms | 15.65 ms | 81 |
| 4 | 4.78 ms | 5.23 ms | 209 |
| 8 | 2.49 ms | 2.75 ms | 401 |
| 16, one per core | 1.54 ms | 1.76 ms | 650 |
| 31, with SMT | 1.66 ms | 4.09 ms | 604 |
| 16, lighting off | 0.40 ms | 0.63 ms | 2,473 |
| 16, CRT filter at 1920×1080 | 2.13 ms | 2.53 ms | 469 |
Hard parts
- More threads made it worse: on 31 threads, using SMT, the average frame only rose from 1.54 to 1.66 ms, but the slowest 1% went from 1.76 to 4.09 ms, 2.3× worse. So the engine runs one worker per physical core.
- Making it thread-safe: the old logic and render threads had race conditions. The rebuild hands the renderer a double-buffered draw list from a fixed 60 Hz tick, and splits each frame by screen tile so no two jobs write the same pixel.
- Making it testable: the old test suite never compiled. Alongside the new 181 cases, an audit of the old code found 13 bugs, including use-after-free and container bugs, all fixed.
Limits
- Windows only: Win32 for the window, XAudio2 for sound and Direct3D 11 to show the finished frame.
- The game renders at 480×270 and scales up by whole numbers (2×, 3× or 4×). The benchmark frame is 640×360; the CRT filter at 1920×1080 output takes a frame to 2.13 ms.
- All the numbers come from one machine, a 16-core Ryzen 9 9950X.
Credits. Art: the Ninja Adventure asset pack by Pixel-boy and AAA (CC0), not my own work. Music and sound effects: AI-generated, locally. Libraries: flecs (ECS), GoogleTest, nlohmann-json and stb_vorbis.








