- Java 100%
| .gitea/workflows | ||
| art | ||
| config/spotbugs | ||
| data | ||
| docs/plans | ||
| gradle/wrapper | ||
| src | ||
| .gitignore | ||
| build.gradle.kts | ||
| CLAUDE.md | ||
| gradlew | ||
| gradlew.bat | ||
| README.md | ||
| settings.gradle.kts | ||
Tower Defense
A 2D tower-defense game written in Java with Swing/AWT. Originally a high-school project (NetBeans, Java 1.5); this repository has been re-laid out into a standard Gradle project. The game logic is unchanged — only the build, package structure, and resource locations were modernized.
Authors: Jay Honnold, Sam Miller
Requirements
- A JDK is needed to run Gradle, but you do not need to install Java 25 yourself — the build declares a Java 25 toolchain and Gradle auto-provisions a matching JDK via the foojay resolver.
Running
./gradlew run
This launches an 800×600 window. The run task uses data/ as its working
directory so the game can read map.txt / level.txt and read/write the
high score in data.txt.
Building
./gradlew build
Project layout
src/main/java/com/towerdefense/ # game source (single package)
src/main/resources/ # bundled assets loaded from the classpath
icon.png
images/ # sprites, tiles, UI
data/ # runtime text data (read/written at runtime)
map.txt level.txt data.txt
art/ # design sources (*.psd), not bundled
Image assets are loaded from the classpath. The three .txt files in data/
are read (and data.txt written) as ordinary files via the EasyReader /
EasyWriter helpers, which is why they live outside the classpath.
Map format (data/map.txt)
First line is width height; the grid follows, one tile code per cell. The
top row is left blank (on-screen text is drawn there). Tile codes:
| Code | Meaning |
|---|---|
| 0 | Empty |
| 1 | Horizontal road |
| 2 | Vertical road |
| 3 | Left to down |
| 4 | Up to right |
| 5 | Up to left |
| 6 | Right to down |
| 7 | Crossroads |
| 8 | Start (facing right) |
| 9 | Finish |
Enemies follow any connected road; the turn tiles (3–7) are cosmetic.