Skip to content

gonewx/pvz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

719 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Plants vs. Zombies AI Recreation

A backend developer with ZERO game development experience recreated "Plants vs. Zombies" using BMAD-METHOD + AI (Claude Code), achieving 120,000+ lines of Go code with 99.9% AI-generated content.

Metric Value
Developer Background Backend engineer, no game dev experience
AI Code Generation Rate 99.9%
Go Source Code 120,000+ lines (388 files)
Development Approach BMAD-METHOD workflow + Claude Code
Manual Intervention Architecture decisions, prompting, review

This project demonstrates that with proper AI workflow management (BMAD-METHOD), even developers without domain expertise can build complex, production-quality applications. The BMAD-METHOD provides structured PRD โ†’ Architecture โ†’ Epic โ†’ Story workflows that guide AI to generate consistent, maintainable code.

CI Release Go Version License

็ฎ€ไฝ“ไธญๆ–‡ | English


๐ŸŽฎ Introduction

This project is a faithful recreation of the classic tower defense game "Plants vs. Zombies" (PC Chinese Anniversary Edition), focusing on learning and practicing Go game development. It adopts the modern Entity-Component-System (ECS) architecture pattern, implements type-safe game logic using Go generics, and aims for 100% reproduction of the original front yard daytime level experience.

Key Features:

  • ๐Ÿ—๏ธ ECS Architecture - Type-safe ECS framework based on Go generics
  • ๐ŸŽจ Original Animations - Complete implementation of the Reanim skeletal animation system
  • โœจ Particle Effects - XML configuration-driven particle system
  • ๐Ÿ“Š Data-Driven - YAML configuration files for game data management
  • ๐ŸŽฏ High Fidelity - Precise recreation of original game values and behaviors

โœจ Features

Implemented Features

Core Systems

  • โœ… Game Framework - Scene management, state machine, main loop
  • โœ… Resource Management - Unified image, audio, and configuration loading system
  • โœ… Sun System - Sky drops and sunflower production
  • โœ… Plant System - Planting, cooldown, card selection
  • โœ… Zombie System - AI, movement, attack, health
  • โœ… Combat System - Projectile collision, damage calculation
  • โœ… Level System - Wave management, progress bar, win/lose detection

Animations & Effects

  • โœ… Reanim Animation System - Original skeletal animation with part transformations
  • โœ… Particle Effects System - Explosions, splashes, dirt particles, etc.
  • โœ… Animation Composition - Multi-animation overlay, track binding, parent-child offsets
  • โœ… Configuration-Driven Animations - YAML configuration for animation compositions

Plants (Chapter 1)

  • ๐ŸŒป Sunflower
  • ๐ŸŒฑ Peashooter
  • ๐Ÿ›ก๏ธ Wall-nut
  • ๐Ÿ’ฃ Cherry Bomb
  • ๐Ÿ’ฅ Potato Mine
  • โ„๏ธ Snow Pea
  • ๐ŸŒฑ Repeater
  • ๐Ÿชด Chomper

Zombie Types (Chapter 1)

  • ๐ŸงŸ Normal Zombie
  • ๐Ÿšง Conehead Zombie
  • ๐Ÿชฃ Buckethead Zombie
  • ๐Ÿšฉ Flag Zombie
  • ๐Ÿ“ฐ Newspaper Zombie
  • ๐Ÿƒ Pole Vaulting Zombie

Level Content

  • โœ… Chapter 1 (Front Yard Daytime) - Levels 1-1 to 1-10
  • โœ… Tutorial System - 1-1 single-row lawn guidance
  • โœ… Special Level - 1-5 Wall-nut Bowling
  • โœ… Conveyor Level - 1-10 Conveyor belt mechanics
  • โœ… Opening Animation - Camera pan, zombie preview
  • โœ… Card Selection Screen - Plant selection, unlock system

UI & Experience

  • โœ… Main Menu System - Start Adventure, Quit Game
  • โœ… Pause Menu - Continue, Restart, Return to Main Menu
  • โœ… Shovel Tool - Remove plants
  • โœ… Lawn Mower Defense - Last line of defense mechanism
  • โœ… Level Progress Bar - Flags, final wave notification

๐Ÿš€ Quick Start

Requirements

  • Go Version: 1.24 or higher
  • Operating System: Windows / macOS / Linux / Android / WASM
  • Memory: At least 2GB RAM
  • Graphics: OpenGL 2.1+ support

Installation & Running

# 1. Clone the repository
git clone https://github.com/gonewx/pvz
cd pvz

# 2. Download dependencies
go mod download

# 3. Run the game
go run .

The game will launch in an 800x600 window.

Building Executables

# Build using Makefile (recommended)
make build                # Build for current platform
make build-linux          # Build for Linux (amd64 + arm64)
make build-windows        # Build for Windows (amd64 + arm64)
make build-darwin         # Build for macOS (requires macOS host)
make build-wasm           # Build for WebAssembly

# Manual build
go build -o pvz-go .

# Build optimized version (smaller size)
go build -ldflags="-s -w" -o pvz-go .

Building Release Version with Icons

# Generate Windows icon resources (.syso)
make generate-icons

# Package Linux release (with icons and .desktop)
make package-linux

# Build macOS .app bundle (requires macOS)
make build-darwin-app

# Build Android APK
make build-apk

# View iOS icon usage instructions
make ios-icons-info

See Quick Start Guide for detailed instructions.

๐Ÿ“– Documentation

User Documentation

Developer Documentation

Note: CLAUDE.md provides development context for the Claude Code AI tool, containing technical details about ECS architecture, Reanim system, etc., primarily for developers.

๐Ÿ—๏ธ Project Structure

pvz/
โ”œโ”€โ”€ main.go                 # Game entry point
โ”œโ”€โ”€ assets/                 # Game resources
โ”‚   โ”œโ”€โ”€ images/             # Image resources (spritesheets)
โ”‚   โ”œโ”€โ”€ audio/              # Audio resources
โ”‚   โ”œโ”€โ”€ fonts/              # Font files
โ”‚   โ”œโ”€โ”€ effect/             # Particle configurations
โ”‚   โ””โ”€โ”€ icons/              # Application icons (multi-platform)
โ”‚       โ”œโ”€โ”€ windows/        # Windows ico and png
โ”‚       โ”œโ”€โ”€ macos/          # macOS iconset
โ”‚       โ”œโ”€โ”€ linux/          # Linux multi-size png
โ”‚       โ”œโ”€โ”€ ios/            # iOS AppIcon.appiconset
โ”‚       โ”œโ”€โ”€ android/        # Android mipmap icons
โ”‚       โ””โ”€โ”€ web/            # Web favicon and PWA icons
โ”œโ”€โ”€ data/                   # Externalized game data
โ”‚   โ”œโ”€โ”€ levels/             # Level configurations (YAML)
โ”‚   โ”œโ”€โ”€ reanim/             # Reanim animation definitions
โ”‚   โ””โ”€โ”€ reanim_config.yaml  # Animation configuration
โ”œโ”€โ”€ pkg/                    # Core code library
โ”‚   โ”œโ”€โ”€ components/         # All component definitions
โ”‚   โ”œโ”€โ”€ entities/           # Entity factory functions
โ”‚   โ”œโ”€โ”€ systems/            # All system implementations
โ”‚   โ”œโ”€โ”€ scenes/             # Game scenes
โ”‚   โ”œโ”€โ”€ ecs/                # ECS framework core
โ”‚   โ”œโ”€โ”€ game/               # Game core managers
โ”‚   โ”œโ”€โ”€ utils/              # Common utility functions
โ”‚   โ””โ”€โ”€ config/             # Configuration loading and management
โ”œโ”€โ”€ scripts/                # Build scripts
โ”‚   โ”œโ”€โ”€ build-apk.sh        # Android APK build
โ”‚   โ”œโ”€โ”€ Info.plist          # macOS app configuration
โ”‚   โ””โ”€โ”€ pvz.desktop         # Linux desktop entry
โ”œโ”€โ”€ docs/                   # Documentation
โ””โ”€โ”€ .meta/                  # Reference materials and metadata

๐ŸŽฏ Tech Stack

  • Language: Go 1.21+
  • Game Engine: Ebitengine v2
  • Architecture Pattern: Entity-Component-System (ECS)
  • Configuration Format: YAML
  • Testing Framework: Go native testing

Core Technical Highlights

  1. Go Generics ECS - Compile-time type safety, 10-30% performance improvement
  2. Reanim Skeletal Animation - 100% reproduction of original animation system
  3. Data-Driven Design - All game values externalized in configuration
  4. High-Performance Particle System - DrawTriangles batch rendering

๐ŸŽฎ Game Controls

Basic Controls

  • Left Mouse Button - Collect sun, select plants, place plants
  • Right Mouse Button - Cancel plant selection
  • ESC Key - Pause/Resume game
  • --verbose - Enable verbose logging (debug)

Gameplay Flow

  1. Select "Start Adventure" from the main menu
  2. Choose plants on the card selection screen (up to 6-10)
  3. Wait for sun, select a plant card
  4. Click on lawn grid to plant
  5. Defend against zombies, complete all waves

See User Manual for detailed instructions.

๐Ÿงช Testing

# Run all tests
go test ./...

# Run tests with coverage
go test -cover ./...

# Generate coverage report
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out

๐Ÿค Contributing

Contributions are welcome! This project is primarily for learning Go game development.

Contribution Process

  1. Fork this repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Create a Pull Request

See Development Guide for detailed guidelines.

๐Ÿ“Š Project Status

MVP Scope

โœ… Completed - Full front yard daytime experience (all 10 levels in Chapter 1)

Completed Epics

  • โœ… Epic 1: Game Basic Framework and Main Loop
  • โœ… Epic 2: Core Resources and Player Interaction
  • โœ… Epic 3: Plant System and Deployment
  • โœ… Epic 4: Basic Zombies and Combat Logic
  • โœ… Epic 5: Game Flow and Advanced Units
  • โœ… Epic 6: Reanim Animation System Migration
  • โœ… Epic 7: Particle Effects System
  • โœ… Epic 8: Chapter 1 Level Implementation
  • โœ… Epic 9: ECS Framework Generics Refactoring
  • โœ… Epic 10: Game Experience Improvements
  • โœ… Epic 11: Level UI Enhancement
  • โœ… Epic 12: Main Menu System
  • โœ… Epic 13: Reanim Animation System Modern Refactoring

Future Plans

  • ๐Ÿ”„ Epic 14+: More levels and features (to be planned)

๐Ÿ“œ License

This project is for learning and technical research purposes only.

See DISCLAIMER.md for important legal notices.

๐Ÿ™ Acknowledgments

  • Workflow Engine: BMAD-METHOD
  • Original Game: "Plants vs. Zombies" by PopCap Games
  • Game Engine: Ebitengine team
  • Development Tool: Claude Code AI

๐Ÿ“ž Contact

For questions or suggestions, please contact us through:


Notice: This project is for learning and technical research only, not for commercial use. All game resource copyrights belong to their original authors.

About

BMad & Spec AI Coding && pvz golang Ebitengine

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages