Skip to content
Game DNA Play a demo

Tower placement & wave spawner

Towers beside a winding road, waves you can preview, upgrades and a boss. A complete starter game you can extend.

Live demoA complete little game: play it, the controls sit beside or under it.

What it does

A tower-defense core: foes march along a fixed road through a grid (one or more paths from waypoint cells); towers go on the grass cells beside it, never on it, so the road can never be blocked.

Made fortower defense and lane defense gamesbase or castle defense stages inside a strategy or adventure gamesurvival levels where the player prepares a route before waves arrivepuzzle-like defense maps with fixed build spots and a road

Tested: 12/12 runs on unseen games passed · visual review 7.6

Moments

Four moments from the demo

Wave 1: mites on the road, three towers firing at them.Play from here
Wave 1: mites on the road, three towers firing at them.
Twin Fords: two roads, moths and spiders, towers by the pond.Play from here
Twin Fords: two roads, moths and spiders, towers by the pond.
Switchback: foes face where they walk; chain lightning arcs.Play from here
Switchback: foes face where they walk; chain lightning arcs.
Placing a mortar: the range ring and ghost on a free grass cell.Play from here
Placing a mortar: the range ring and ghost on a free grass cell.

Take it home

Hand it to your agent

  1. Copy the prompt. It is written for a game your agent has never seen.
  2. Give it the module (tower-defense.js) and its README.
  3. Play your game. The prompt ends with checks your agent can run.
ModuleREADME
prompt.md · 74 lines
# Add Tower placement & wave spawner to my game

Add the game element below to MY existing game, which you have not seen. It is a finished module file given with this prompt:

- `tower-defense.js` (one global, `GameDNA_TowerDefense`), API reference `tower-defense.README.md`

README example names are placeholders.

## Shared premises

1. **Include each module file verbatim; never edit it.** Load it with its own `<script src>` before the game's script, or paste it unchanged into its own `<script>` tag. If a module seems to need a change, adapt my game around it and tell me.
2. **Resolution:** keep my game's native resolution and integer scaling as they are. Call module draw functions on my 2D context inside the same transform as my sprites (one module pixel = one game pixel), and keep my game's own image-smoothing setting (off for pixel art, on for smooth or HD games; never switch it).
3. **Time:** drive every module from one fixed 60 Hz step (1000 / 60 ms). If my loop uses variable delta time, accumulate it and run whole steps (at most 250 ms per frame).
4. **Coordinates:** native screen pixels (world minus camera) unless a section says tiles.
5. **Art and names:** anything new you draw or name is original (no real game, character, place or brand names); English UI text; do not restyle my game.
6. **Hook, don't replace:** add calls or change bodies; never delete or rename a function.
Open the whole prompt