A tower defense game built with Java and Processing, featuring wave-based combat, strategic tower placement, and progressive difficulty. Defend the wizard's house from waves of monsters by strategically placing and upgrading towers along their path.
- Features
- Gameplay
- Controls
- Installation
- How to Run
- Game Mechanics
- Configuration
- Project Structure
- Architecture
- Technologies Used
- Development
- Tower Defense Gameplay: Place and upgrade towers to defend against monster waves
- Strategic Depth: Multiple upgrade paths (range, speed, damage) for towers
- Wave System: Progressive difficulty with multiple monster types and waves
- Mana Economy: Earn and manage mana to build and upgrade towers
- Multiple Levels: 4 different map layouts with unique challenges
- Pause & Fast-Forward: Control game speed to strategize or speed through waves
- Visual Feedback: Real-time tower indicators, projectile effects, and UI tooltips
- Win/Loss Conditions: Survive all waves to win, lose if your wizard house is destroyed
You play as a wizard defending your house from waves of monsters (gremlins, beetles, and worms) that travel along predetermined paths. Place towers strategically to attack monsters as they approach. Earn mana by killing monsters and use it to build more towers or upgrade existing ones.
- Win: Survive all monster waves and eliminate every monster
- Lose: Your wizard house takes too much damage and is destroyed
- Gremlin: Basic enemy with varying HP, speed, and armor
- Beetle: Armored enemy with higher defense
- Worm: Fast-moving enemy with lower HP
| Key | Action |
|---|---|
T |
Toggle tower placement mode |
1 |
Toggle range upgrade mode |
2 |
Toggle speed upgrade mode |
3 |
Toggle damage upgrade mode |
M |
Upgrade mana pool |
P |
Pause/Unpause game |
F |
Toggle fast-forward (2x speed) |
R |
Restart game |
- Left Click: Place towers or click UI buttons
- Hover: View tower upgrade costs and information
- Java 8 or later (Java 8 recommended for best compatibility)
- Gradle (included via Gradle wrapper)
- Git (for cloning the repository)
git clone https://github.com/aryankumawat/Maze-Tank-Game.git
cd Maze-Tank-Game# Make gradlew executable (first time only)
chmod +x gradlew
# Run with Java 8 (recommended)
JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home ./gradlew run
# Or if Java 8 is your default
./gradlew rungradlew.bat run# Build the JAR
./gradlew jar
# Run the JAR with Java 8
java -jar build/libs/MazeTanks-1.0.jar- Starting Mana: 200 (configurable)
- Mana Regeneration: 2 mana per second (configurable)
- Earning Mana: Kill monsters to gain mana
- Spending Mana: Build towers (100 mana) or upgrade them
- Base Stats:
- Range: 96 pixels
- Firing Speed: 1.5 shots per second
- Damage: 40 per hit
- Upgrades: Each tower can be individually upgraded
- Range: Increase attack radius
- Speed: Fire projectiles faster
- Damage: Deal more damage per hit
- Placement: Can only be placed on grass tiles (marked with 'S')
- Multiple waves with varying difficulty
- Pre-wave pause between waves for preparation
- Different monster types with unique stats per wave
- Wave information displayed in the top bar
The game is configured via config.json:
{
"layout": "level2.txt", // Map file to load
"waves": [...], // Wave configuration
"initial_tower_range": 96,
"initial_tower_firing_speed": 1.5,
"initial_tower_damage": 40,
"initial_mana": 200,
"initial_mana_cap": 1000,
"initial_mana_gained_per_second": 2,
"tower_cost": 100,
"mana_pool_spell_initial_cost": 100,
"mana_pool_spell_cost_increase_per_use": 150,
"mana_pool_spell_cap_multiplier": 1.5,
"mana_pool_spell_mana_gained_multiplier": 1.1
}level1.txt,level2.txt,level3.txt,level4.txt- Map format:
X: Path tiles (where monsters travel)W: Wizard house (your base)S: Shrub/grass (where towers can be placed): Empty space
Maze-Tank-Game/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── WizardTD/
│ │ │ ├── App.java # Main application entry
│ │ │ ├── Resources.java # Resource loader
│ │ │ ├── data/ # Data structures
│ │ │ │ ├── config/ # Configuration classes
│ │ │ │ ├── Point.java
│ │ │ │ ├── Rectangle.java
│ │ │ │ └── RectangleF.java
│ │ │ ├── game/
│ │ │ │ ├── GameScreen.java # Main game screen
│ │ │ │ ├── GameMap.java # Map parser
│ │ │ │ ├── board/ # Game board & layers
│ │ │ │ │ ├── Board.java
│ │ │ │ │ ├── layer/ # Rendering layers
│ │ │ │ │ └── object/ # Game objects
│ │ │ │ │ ├── Monster.java
│ │ │ │ │ ├── Tower.java
│ │ │ │ │ └── Fireball.java
│ │ │ │ ├── logic/ # Game controllers
│ │ │ │ │ ├── GameController.java
│ │ │ │ │ ├── ManaController.java
│ │ │ │ │ └── WaveController.java
│ │ │ │ └── ui/ # Game UI
│ │ │ ├── ui/ # UI components
│ │ │ └── util/ # Utility classes
│ │ └── resources/
│ │ └── WizardTD/ # Game assets (images)
│ └── test/ # Unit tests
├── build.gradle # Build configuration
├── config.json # Game configuration
└── level*.txt # Level maps
graph TD
A[App - Main Entry] --> B[GameScreen]
B --> C[TopBar]
B --> D[SideBar]
B --> E[Board]
B --> F[GameController]
E --> G[BackgroundLayer]
E --> H[RoadLayer]
E --> I[WizardHouseLayer]
E --> J[TowerLayer]
E --> K[MonsterLayer]
E --> L[FireballLayer]
E --> M[EndGameLayer]
F --> N[WaveController]
F --> O[ManaController]
J --> P[Tower Objects]
K --> Q[Monster Objects]
L --> R[Fireball Objects]
sequenceDiagram
participant User
participant GameController
participant WaveController
participant Board
participant Tower
participant Monster
participant ManaController
User->>GameController: Start Game
GameController->>WaveController: Initialize Waves
GameController->>ManaController: Set Initial Mana
loop Game Loop (60 FPS)
WaveController->>Board: Spawn Monster
Board->>Monster: Create & Add to Path
Tower->>Monster: Detect in Range
Tower->>Board: Fire Fireball
Board->>Monster: Apply Damage
alt Monster Killed
Monster->>ManaController: Award Mana
Monster->>Board: Remove Monster
else Monster Reaches House
Monster->>ManaController: Reduce Mana/Health
end
User->>GameController: Build/Upgrade Tower
GameController->>ManaController: Check & Deduct Mana
ManaController->>Board: Place/Upgrade Tower
end
alt All Waves Complete
GameController->>Board: Display Win Screen
else Wizard House Destroyed
GameController->>Board: Display Loss Screen
end
flowchart LR
A[config.json] --> B[Config Class]
B --> C[GameController]
B --> D[WaveController]
B --> E[ManaController]
F[level.txt] --> G[GameMap]
G --> H[Board]
C --> I[Game State]
D --> J[Monster Spawning]
E --> K[Mana Pool]
J --> L[Monster Objects]
K --> M[Tower Creation]
M --> N[Fireball Creation]
N --> L
- Language: Java 8
- Framework: Processing 3.3.7 - Graphics and game loop
- Build Tool: Gradle 8.2
- Testing: JUnit 5
- Libraries:
- Google Guava 28.0
- Processing Core 3.3.7
./gradlew build./gradlew test./gradlew jacocoTestReportCoverage reports will be in build/reports/jacoco/test/html/
- IntelliJ IDEA: Import as Gradle project
- Eclipse: Import as existing Gradle project
- VS Code: Use Java Extension Pack and Gradle for Java
- Component Pattern: UI elements extend
Componentclass - Layer System: Game rendering uses separate layers for different elements
- Controller Pattern: Game logic separated into controllers (Game, Wave, Mana)
- Configuration-Driven: Game parameters loaded from JSON
- Towers: Defensive structures that shoot fireballs at monsters
- Monsters: Various enemy types following paths
- Wizard House: Your base that must be protected
- UI: Sidebar with controls and stats, top bar with wave info and mana
This is a personal project, but suggestions and feedback are welcome! Feel free to:
- Report bugs via GitHub Issues
- Suggest new features
- Fork and experiment with your own modifications
Aryan Kumawat
- GitHub: @aryankumawat
- Repository: Maze-Tank-Game
- Built with Processing framework
- Inspired by classic tower defense games
- Game assets and sprites custom-designed for this project
Enjoy the game! Good luck defending the wizard house!