Building AI Dodge — From Zero to Playable with DeepSeek and Phaser.js
We built a complete browser game using AI as a co-developer. Here's the full walkthrough — prompts, iterations, and the playable result.
Forget writing every line of game code by hand. In this post, we used DeepSeek to build AI Dodge — a game where you survive AI-controlled enemies that hunt you down. The entire game was built in under an hour, and you can play it right now.
Play the Game
Move with WASD or arrow keys. Survive as long as you can. Press R to restart.
The Prompt Chain
Here’s exactly how we built this, prompt by prompt.
Prompt 1: Scaffold
“Create a Phaser.js 3 game where the player is a blue circle that moves with WASD/arrows. Red circles spawn from screen edges and chase the player with simple AI. Score increases over time. Collision = game over. Include a restart on R key.”
The AI generated the full HTML file in one shot. The initial version worked but had:
- No enemy speed scaling
- Score timer stacking bug (every frame adding a new timer)
- Enemies could get stuck offscreen
Prompt 2: Polish
“Fix the score timer bug — use a single looping timer instead. Speed up enemies gradually as score increases. Wrap enemies that go offscreen. Add a subtle glow effect to the player.”
All fixes applied cleanly. The game was playable after two prompts.
How the AI Works
The enemy AI is a steering behavior — about 10 lines of logic:
// Each frame, enemies steer toward the player
const dx = player.x - enemy.x;
const dy = player.y - enemy.y;
const dist = Math.sqrt(dx*dx + dy*dy);
const spd = enemy.getData('speed');
enemy.setVelocity(
(dx / dist) * spd,
(dy / dist) * spd
);
That’s it. No pathfinding, no state machines — just seek behavior. The difficulty comes from:
- Spawn rate — New enemies appear every 2.2 seconds
- Speed scaling — Enemies start at 60px/s and gain +2 per score point (up to 140)
- Numbers — More enemies accumulate over time
What AI Did vs. What We Fixed
| Aspect | AI Generated | Manual Fix |
|---|---|---|
| Core gameplay | Phaser scene, player movement, enemy AI, collision | — |
| Score timer | Buggy (stacking events) | Single loop timer |
| Enemy wrap | Missing | Added offscreen wrapping |
| Speed scaling | Missing | + score * 2 scaling |
| Polish | Basic | Player glow tween, screen wrapping |
Token & Cost Breakdown
Built iteratively across 5 prompt-response cycles with DeepSeek V4 Flash:
| Metric | Amount |
|---|---|
| Total output tokens | ~25K (game code across revisions) |
| Total input tokens | ~50K (prompts + context) |
| DeepSeek V4 Flash rate | $0.14/M input · $0.42/M output |
| Actual cost | ~$0.02 (most input was cache-hit at $0.0028/M) |
The entire game cost less than a nickel in API usage — cheaper than a cup of coffee, and the AI did all the boilerplate.
Why This Matters for Game Dev
AI tools collapse the time from idea → playable prototype dramatically. What took two prompts could have been hours of manual boilerplate. The key insight:
AI handles 80% of the code. You handle the 20% that makes it fun.
The fixes weren’t hard — they just needed a human to notice the bugs and direct the next iteration. That’s the current sweet spot for AI game development.
Try It Yourself
Grab the source and remix it:
<!-- Load Phaser, add your game logic -->
<script src="https://cdn.jsdelivr.net/npm/phaser@3.60.0/dist/phaser.min.js"></script>
The complete game is just 80 lines of JavaScript. Clone the code from our GitHub repo and try:
- Adding power-ups
- Different enemy types (fast/small, slow/big)
- A leaderboard
- AI that learns your movement patterns
What’s Next
This is just the start. Upcoming posts will cover:
- AI-generated sprites with Stable Diffusion → game-ready
- Behavior trees for smarter enemy AI
- 3D game prototypes with Three.js + AI prompts
- Full game jam — build a complete game in 24 hours with AI
Play the game above, and follow along as we push what’s possible with AI game development.