QtowerDefense
-
Hi everyone,
after QtCraft I couldn't leave it alone, so here is the next one: QtowerDefense, a fantasy tower defense game in 3D, written in C++23 with Qt 6.12 and Qt Quick 3D.

Same premise as last time: how far can an AI agent (Claude Code) take a non-trivial Qt project more or less on its own? I set the direction, answered the open questions, play-tested and reviewed; the code is the agent's. This time it took about a week, from the first commit to 1.0.0.
QtCraft renders through its own little "engine" on top of QRhi. QtowerDefense doesn't: everything is plain Qt Quick 3D on the scene graph, with instanced models for towers, enemies and shots, and Qt Quick for the HUD. That was the part I was most curious about, whether you can make a real game with what Qt already ships, without writing a renderer.
Short answer: yes.
Longer answer: you run into the scene graph's own habits. My favourite: with vsync off, the frame rate sat at about 167 FPS no matter how light the scene was. That isn't the GPU. The threaded render loop drives its animations with a timer of 1000 / refresh rate ms, 6 ms on my 143 Hz screen. With QSG_USE_SIMPLE_ANIMATION_DRIVER=1 it went to about 400, with QT_QPA_UPDATE_IDLE_TIME=0 on top to almost 4,000. Irrelevant for the game itself (it runs with vsync), but it cost a while to understand why the benchmark refused to move x)
The guard rails:
Mostly the same as for QtCraft (static analysis, sanitizers, a decision log, independent review agents before every merge, CI for Windows, macOS, Linux and the browser), plus a few that fit the genre:
- The simulation is deterministic: fixed tick, fixed-point maths, its own random generator, no float/double in the core. So a game is just a seed plus a list of commands.
- Golden replays: recorded games whose state hashes have to come out the same on every compiler and platform.
- Bots and the human use the same commands. The agent can play the real game in the window through a control interface, and a smoke test plays it on every full check.
- Content is JSON only: maps, waves, towers, enemies.
- A bit over 600 test cases (C++ and QML), 55 entries in the decision log.
The game contains:
- A campaign on a world map in the fog, nine sections with their own landscapes, stars per map, plus an endless mode
- 7 tower types with upgrades and target priorities; towers come as cards you roll for and drag onto the map
- 8 enemy types and 2 bosses, damage types, resistances, slowing and poison
- A hero who comments on the battle, with two spells
- Faster/slower play, calling waves early, saving a running game
- Mouse and touch, English and German
- Models from Kenney (CC0); nothing taken from existing games

The menus are plain Qt Quick:

Supported platforms
Windows, macOS and Linux as packages, and it runs in the browser (WebAssembly). iOS and Android build from source and were played in the simulator/emulator, no store packages.
It isn't as polished as QtCraft, and I think I know why. For QtCraft the agent had a very concrete model to work towards; everybody knows what a block world is supposed to feel like. This time the brief came out of a short quiz, was a lot vaguer, and explicitly said not to copy any existing game. Without a direct blueprint, the agent fills the gaps with "reasonable" decisions, and reasonable is not the same as fun. The game is complete and playable, but you can tell that game design is the part where it needed me more than I expected.
You can try it here:
- Play in the browser: https://deivadder.github.io/QtowerDefense/ (about 53 MB, the first start takes a moment)
- Repository: https://github.com/DeiVadder/QtowerDefense
- Releases: https://github.com/DeiVadder/QtowerDefense/releases
As before, I'm grateful for any feedback, on the game, the code or the approach.
-
J J.Hilk marked this topic as a regular topic
-
Played two maps last night on Windows and lost track of time, the little enemy waves look great. I'm not a developer at all, my partner sent me the link, so I can't say anything smart about the scene graph part, but it runs smoothly on our old laptop. Would love a slower "relaxed" difficulty, the third wave got me every time :)