Vibe Arcade Blog

Dev stories, game design, and the art of building with AI

How We Built Deadlock With AI: When the Win Condition Has Three Outcomes Instead of Two

We asked for a reverse tower defense where the player is the villain. The AI proposed a cage mechanic that splits the win state in half — and the entire tactical layer of the game collapsed neatly into that one rule.

· Vibe Arcade

game dev vibe coding tower defense behind the scenes

Most tower defense games end in one of two ways: you survive the wave, or you don't. Deadlock doesn't work that way. Every level has three outcomes — full win, partial win, and loss — and the difference between the two wins is whether the cage was ever cracked open, even once. That single design rule is the most interesting thing about the game, and it was locked into the spec before a line of code was written.

This post is the story of how Deadlock came together: the rule, the build burst that shipped three iterations in one night, the room layout that emerged unprompted, and the bugs that taught us something about iframe games versus integration tests.

Want to play first, then read the build story?

▶ Play Deadlock Now

The Brief, and the One Rule That Couldn't Be Touched

The genre target was reverse tower defense — Castle Doombad, Evil Genius, Dungeon Keeper as reference points, but compressed into a single short browser session. The player is the rogue station AI. You've captured the fleet commander. The humans keep sending boarding parties to break him out. Your job each level is to place automated traps and trigger manual weapons to kill every boarder before they smash the cage and carry the commander to the airlock.

The pitch fits in one sentence. The design pillar fits in two: every level has three outcomes, not two. Once the cage is cracked it stays cracked for the rest of the level, so killing every boarder after that is a partial win — you cleared the room, but the tactical integrity of your deadlock was broken.

The spec marked that rule as non-negotiable in capital letters. Every later iteration — new weapons, new heroes, new room layouts — went through that lens. Did the new feature reinforce the cage-defense pressure, or just add offensive power against the spawn? The pillar held the design honest.

Why three outcomes matter: Binary win/lose collapses every tactical question into "more damage." Splitting the win state forces players to think about the captive's safety as a separate axis from kill efficiency. The most rewarding play isn't "wipe the room fastest" — it's "wipe the room without ever letting them touch the cage." That's a fundamentally different game.

The Villain POV, Enforced at the Vocabulary Layer

The first design call after locking the cage rule was about language. The player is the villain in this game, and the framing has to land in every visible string. Internal code keeps neutral variable names like hero because grep is grep, but every user-facing label calls the incoming humans boarders, invaders, or rescue teams. The captive isn't being saved — he's being extracted. The mission isn't being defended — the deadlock is being maintained.

This sounds like a small thing. It isn't. Reverse tower defense games that fail to commit to the villain framing tend to feel like regular tower defense with the polarity flipped. Deadlock commits at the vocabulary layer, and that commitment is part of why the role feels distinctive in play.

Three Iterations in One Night

The first build night ran iter 1 through iter 3 in roughly 33 minutes between commits. The pace wasn't accidental — the structured pipeline that builds these games is designed to compress design-and-test loops, and Deadlock's tight scope let it move fast.

The QA rubric scored the three iterations 46, 53, and 58 out of 60. Iter 3 cleared the ship threshold cleanly without needing a fourth pass. That's unusual for the pipeline at the time — most builds needed iter 4 to clear — and it's largely because the design pillar kept the scope tight.

Castle Doombad Rooms Weren't in the Spec

The original spec said almost nothing about room geometry. It described the cage, the airlock, and the requirement that boarders had to traverse the station to reach the cage. That was it.

The first room layout that worked well — narrow corridors, staircase staggers, ladders that competed with doors as paths, ceiling holes that opened a third lane of attack — emerged from a single commit a few days post-ship. It made the trap-placement decisions tactically rich without requiring a tile editor or a designer. Once the pattern proved out, it expanded into a five-stage progression over the following week, with each stage adding a layout twist: narrow rooms, then wave ramping, then a loop layout, then fully non-linear traversal.

The valuable lesson here was that pattern-emergence beats pattern-prescription. If the spec had locked in a specific room layout, we'd have spent the week debugging the spec instead of expanding the pattern.

Procedural Sprites First, Real Art via Feature Flag

Iter 1 shipped with everything drawn procedurally — fillRect, arc, polylines, no image assets at all. The walls were rectangles. The boarders were silhouettes built from primitives. The traps were geometric shapes with particle bursts on activation.

This was a deliberate scope decision. Generating a full sprite sheet would have blocked the first ship by hours. The procedural pass got the game playable; the visual upgrade ran on a separate track.

About a week later, sixty-three sprite PNGs landed across three phases (heroes and weapons, then environment, then UI and effects), gated behind an ASSETS_AVAILABLE feature flag. The flag pattern is worth keeping: it meant the procedural fallbacks remained intact for any device where the asset preload failed, and it let the asset rework iterate independently of the game logic.

The Walk Cycle That Couldn't Be Integrated

Roughly a week post-ship, a user report landed: the boarders looked like they were sliding instead of walking. Two existing sprite frames, no animation between them, and the result read as a glide rather than a step.

The first fix attempt was a walk-cycle integration PR — sixteen sprite frames, a four-frame cycle per boarder, full animation logic in the render path. The PR looked clean in review. It was merged. It broke the iframe load on the live page.

The PR was reverted within hours. The eventual fix shipped a few days later as something strictly simpler: track hero.facing as +1 or -1 based on movement direction, mirror the hero body via ctx.scale(-1, 1) when facing left, and add a sin-phase vertical bob (about 7% of a tile height) when in a walking state. Critically, each boarder gets a phase offset based on their ID, so a group of marines shuffles into the room instead of marching in lock-step.

What we learned about iframe games: PR-review cleanliness does not imply iframe-load correctness. For child-iframe games, a smoke-test load is the right gate before merge — not just the lint pass. The walk-cycle revert is a useful negative result we keep referring back to.

Other Bugs Worth Mentioning

A few user-reported bugs shaped the post-ship improvement wave more than the original spec did:

The Name

Deadlock was chosen over Containment, Kill Switch, and Sentinel Loop. The triple meaning landed it: the locked cage holding the captive, the stalemate the player is trying to maintain between spawn and exit, and the computing term for a process that can't progress — which fits the rogue-AI framing. Short, strong consonants, distinctive against the existing thirty-plus-game roster, no token collisions in the name-check pass.

What Makes Deadlock Different

Reverse tower defense as a genre is less crowded than regular tower defense, but it still has well-established conventions. What Deadlock adds to those conventions is the cage-as-second-axis design — every tactical decision has to account for both the kill rate and the cage exposure, and the partial-win state means there's always something left to play for even in a level you can't fully ace.

The tight scope (one captive, one airlock, three outcomes) keeps the decision space legible. The Castle Doombad-style room layouts keep the trap placement interesting. The villain framing keeps the role distinctive. None of these were obvious until the spec committed to them — which is the broader lesson here: the design pillars matter more than the feature list.

Play Deadlock →

Related: Free Tower Defense Browser Games: Play Online Now · How We Built CyberCircuit · What Is Vibe Coding? · Vibe Coding Tools: From Chatbots to AI IDEs