A modern tower defense game built entirely by Claude Code - demonstrating AI-powered game development with clean architecture and engaging gameplay.
This is a complete tower defense game featuring:
- ๐ฎ Wave-based enemy spawning with progressively harder enemies
- ๐ฐ Economic system with upgrades and permanent progression
- โก Active abilities and kill streak bonuses
- ๐จ Smooth animations and visual effects
- ๐ Simulator for testing game balance
- ๐พ Persistent progress with essence-based meta-progression
This entire game was created by Claude Code, showcasing how AI can build production-ready applications with:
- Clean, modular architecture
- Type-safe TypeScript implementation
- Performance-optimized rendering
- Comprehensive game systems
- Node.js 18+ and npm
- Modern web browser with WebGL support
# Clone the repository
git clone https://github.com/mdkess/claude-game.git
cd claude-game
# Install dependencies
npm install
# Run development server
npm run dev
# Build for production
npm run build
# Run tests/simulator
./test-simulator.sh balanced 120 summaryAccess debug features by adding ?debug=true to the URL:
http://localhost:3000/?debug=true
Debug mode enables:
- DEBUG: -100 HP - Deal 100 damage to your tower
- DEBUG: +1000 Gold - Add 1000 gold instantly
- DEBUG: +100 Essence - Add 100 essence instantly
The game uses a clean, decoupled architecture with clear separation of concerns:
game/
โโโ core/
โ โโโ GameCore.ts # Core game logic (no rendering)
โ โโโ EventEmitter.ts # Event system for loose coupling
โ โโโ constants.ts # Game configuration
โโโ entities/
โ โโโ Enemy.ts # Enemy logic (no graphics)
โ โโโ Tower.ts # Tower defense logic
โ โโโ Projectile.ts # Projectile physics
โโโ systems/
โ โโโ WaveSystem.ts # Wave spawning logic
โ โโโ CombatSystem.ts # Combat calculations
โ โโโ UpgradeSystem.ts # Upgrade progression
โโโ renderers/
โ โโโ EnemyRenderer.ts # PIXI rendering for enemies
โ โโโ TowerRenderer.ts # Tower visuals
โ โโโ ProjectileRenderer.ts
โโโ Game.ts # Main game class (extends GameCore with rendering)
-
Separation of Logic and Rendering
GameCorecontains all game logic without any graphics- Renderers handle all visual representation
- Enables headless simulation for testing
-
Entity Component System
- Entities (Enemy, Tower, Projectile) contain only data and logic
- Renderers manage the visual representation
- Clean separation allows for easy testing and different render targets
-
Event-Driven Architecture
- Systems communicate through events
- Loose coupling between components
- Easy to extend with new features
-
Object Pooling
- Enemies and projectiles are pooled for performance
- Reduces garbage collection pressure
- Smooth performance even with many entities
- GameCanvas.tsx: Main React component that initializes the game
- GameUI.tsx: HUD and upgrade interface
- EssenceMenu.tsx: Permanent upgrade shop
- HeadlessGame.ts: Extends GameCore for simulation without graphics
- Simulator.ts: Runs automated gameplay with different strategies
- strategies.ts: AI strategies for testing game balance
- Tower automatically targets nearest enemy
- Projectile physics with collision detection
- Multi-shot and bounce mechanics for upgraded towers
- Hand-crafted early waves for balanced difficulty curve
- Procedural generation after wave 10
- Multiple enemy types:
- Basic: Standard enemies
- Swarm: Fast, weak enemies that spawn in groups
- Tank: Slow, high-health enemies
- Splitter: Enemies that split into swarms when killed
- Offensive: Damage, Fire Rate, Range
- Defensive: Max Health, Health Regeneration
- Economic: Gold per Round, Interest
- Starting stats boosts
- Economic multipliers
- Special abilities (multi-shot, bounce)
- Speed Boost: Active ability with cooldown
- Kill Streaks: Chain kills for damage bonuses
- Perfect Waves: Bonus gold for taking no damage
- Interest System: Earn percentage of current gold per second
src/
โโโ app/ # Next.js app directory
โโโ components/ # React components
โโโ game/ # Game logic and rendering
โ โโโ core/ # Core game systems
โ โโโ entities/ # Game objects
โ โโโ systems/ # Game mechanics
โ โโโ renderers/ # Visual components
โ โโโ effects/ # Visual effects
โโโ simulator/ # Balance testing tools
- React + Next.js: Modern web framework
- TypeScript: Full type safety
- PixiJS v8: High-performance 2D rendering
- Tailwind CSS: Utility-first styling
Run the simulator to test different strategies:
# Test balanced strategy for 2 minutes
./test-simulator.sh balanced 120 summary
# Test with permanent upgrades
./test-simulator.sh balanced 120 summary 5 2 3 1 1 0.5 0.5
# Test all strategies
for strategy in cheapest damage balanced tank adaptive greedy economic; do
echo "Testing $strategy..."
./test-simulator.sh $strategy 60 summary | grep "Survived:"
doneThis project was created as a demonstration of AI-powered development. Feel free to:
- Report bugs or suggest features
- Fork and create your own variations
- Use as a template for your own games
MIT License - feel free to use this code for any purpose!
Created entirely by Claude Code (Anthropic's Claude) - demonstrating the capabilities of AI-assisted software development for complex, production-ready applications.
Special thanks to the open-source libraries that made this possible:
- PixiJS for rendering
- Next.js for the framework
- TypeScript for type safety
