Make a Tower Defense Game With Targeting, Gold and Waves
Build Lane Watch: three tower slots, eight enemies, limited gold and a defended exit.

Thumbnail: an actual matching workshop game. It is a gameplay reference, not evidence that a save, inventory, network or native reverse-engineering integration has been demonstrated.
Difficulty: beginner to intermediate. Prerequisites: basic variables, functions and a test copy of your project. Reference: Forge workshop 1.0, browser ES modules and Node 24 checks. Engine-specific translation is a separate integration.
What you will build
Defend one lane against eight enemies using up to three towers.
Play Lane Watch →Download complete MIT workshop- Extract into a new folder and run
node check.mjsfrom that folder. - For the browser games, run
python3 -m http.server 8080with Python 3 and openhttp://localhost:8080/index.html. Do not open modules with file://. - Read the full setup instructions and the original code licence. Keep your existing game on a separate test branch.
The JavaScript behaviour checks and native C comparison can run independently of the browser. Ghidra UI, physical-phone and your engine integration are separate checks. This is a small reference, not a certification of your project.
Explore the related game idea · Start with Build a Game · Improve your existing game
Five practical steps
Prove the path before combat
Start Tower defence in the workshop. Enemies travel left to right along one lane. Each enemy owns progress and health; reaching the exit costs a life. Eight enemies spawn at bounded intervals, so this first wave can actually finish.
Expected result: A visible lane, five lives and a finite wave.
Check it: Run without towers; escaped enemies reduce lives and eventually end the game.
stepObserve the inputs → check the state → compare the resultMake purchase checks atomic
Click a slot button. tower.action checks a valid slot, available gold and no existing tower before deducting six gold and creating the tower. Use a single purchase function for mouse, keyboard and touch.
Expected result: Twelve starting gold buys two unique towers.
Check it: Click the same slot twice or a third slot without enough gold; neither charges again.
Choose a deliberate target
For each ready tower, filter living enemies within range and choose the one farthest along the lane. Resolve one hit and restart its cooldown. Range is horizontal distance in this one-lane prototype; a winding path needs path progress and actual 2D distance.
Expected result: A tower attacks a valid target every 0.65 seconds.
Check it: Put two enemies in range and confirm the one closer to the exit is chosen.
Resolve death and reward once
Apply all hits, then award two gold for each newly defeated enemy and remove it. Defeated enemies must not also cost an exit life. End the wave only when the spawn queue and active list are empty.
Expected result: No duplicate gold and no premature victory between spawns.
Check it: Watch a defeated enemy at the exit and verify one reward, no life loss and no remaining dead object.
Add a balanced second wave
Keep the first wave beatable with sensible purchases. Add a second wave table with explicit count, health and speed rather than an endless formula. Explain tower range and cooldown in UI before adding art or complicated upgrade trees.
Expected result: A complete small defence loop with purchases, combat and outcome.
Check it: Test a no-purchase loss, two-tower win, pause and repeated restart before tuning a new wave.
Read and reuse the actual code
tower.mjs: complete source · Standalone behavioural checks · Shared browser runner and input. Original BINX Forge code, MIT; the package includes every required file and its notice.
Inspect complete tower.mjs
export function create(){return {enemies:[],towers:[],gold:12,lives:5,spawn:0,remaining:8,kills:0,ended:false,won:false};}
export function action(s,slot){if(s.ended||![0,1,2].includes(slot)||s.towers.some(t=>t.slot===slot)||s.gold<6)return false;s.gold-=6;s.towers.push({slot,x:120+slot*180,cool:0});return true;}
export function step(s,i,dt){
if(s.ended)return;
s.spawn-=dt;if(s.remaining>0&&s.spawn<=0){s.enemies.push({x:0,hp:2});s.remaining--;s.spawn=1.8;}
for(const e of s.enemies)e.x+=45*dt;
for(const t of s.towers){t.cool-=dt;const target=s.enemies.filter(e=>e.hp>0&&Math.abs(e.x-t.x)<115).sort((a,b)=>b.x-a.x)[0];if(target&&t.cool<=0){target.hp--;t.cool=.65;}}
for(const e of s.enemies){if(e.hp<=0){s.gold+=2;s.kills++;}else if(e.x>620)s.lives--;}
s.enemies=s.enemies.filter(e=>e.hp>0&&e.x<=620);
if(s.lives<=0||(!s.remaining&&!s.enemies.length)){s.ended=true;s.won=s.lives>0;}
}
Code rights: the included MIT notice permits use, modification and distribution, including commercial games and source products, with the copyright and licence notice. Added third-party files have their own terms. Read the official licence & usage terms.
Common failures and fixes
The wave wins too early
Wait for both remaining spawns and active enemies to reach zero.
Gold multiplies on a corpse
Remove rewarded enemies once; do not award in every tower callback.
The target feels random
Document a priority rule such as furthest progress; do not rely on array insertion accidentally.
Make Your Game Better
Change one system after the baseline works. Keep the free reference and compare the same inputs before and after.
Add wave data
Keep wave rules in a table and test every finite wave from a fresh state.
Add tower inspection
Show range and fire interval before purchase; a more attractive model does not improve targeting.
Optional building blocks from original creators

Godot Engine contributors · Original screenshot ↗ · CC BY 4.0 ↗. Resized and compressed.
Godot Engine contributorsGodot
Free, open-source game editor for 2D and 3D projects, with scene, animation and interface tools.

UI Pack
Interface artwork for buttons, panels and sliders.
Inspect exact formats and editions on each resource page. Pay for a resource only when it fills an identified gap; the free code exercise needs no paid engine or pack.
Licensing summary, not legal advice. Before publishing or selling, check exact terms for finished-game use, reselling files and including files in a source/template product separately.
Learn at the original sources
Sources checked 11 October 2026. The numbered plan is original Forge instruction; linked documentation does not imply every engine or device has been tested.
Take this guide to your AI
Review and copy into your assistant. Nothing is sent automatically. These prompts include the complete focus source, full-package links, checks and compatibility limits.
Review a prompt or select its text manually.