An old tower defense written in java (2011)
Find a file
2026-06-23 20:11:32 -07:00
.gitea/workflows Add Gitea Actions CI with Spotless + SpotBugs (#2) 2026-05-31 18:33:09 -07:00
art Modernize project layout: Gradle + standard structure 2026-05-31 16:35:27 -07:00
config/spotbugs Logic pass: fix latent bugs, drop 3 SpotBugs exclusions, Direction enum, renderer DRY (#3) 2026-05-31 19:28:22 -07:00
data Modernize project layout: Gradle + standard structure 2026-05-31 16:35:27 -07:00
docs/plans docs: add in plan docs from recent refactors 2026-06-23 20:11:32 -07:00
gradle/wrapper Modernize project layout: Gradle + standard structure 2026-05-31 16:35:27 -07:00
src Fix enemy kills awarding $0 money for speed-1 enemies (#4) 2026-05-31 19:51:28 -07:00
.gitignore Modernize project layout: Gradle + standard structure 2026-05-31 16:35:27 -07:00
build.gradle.kts Add Gitea Actions CI with Spotless + SpotBugs (#2) 2026-05-31 18:33:09 -07:00
CLAUDE.md Add CLAUDE.md with agent-facing operational knowledge 2026-05-31 19:31:36 -07:00
gradlew Modernize project layout: Gradle + standard structure 2026-05-31 16:35:27 -07:00
gradlew.bat Modernize project layout: Gradle + standard structure 2026-05-31 16:35:27 -07:00
README.md Modernize project layout: Gradle + standard structure 2026-05-31 16:35:27 -07:00
settings.gradle.kts Modernize project layout: Gradle + standard structure 2026-05-31 16:35:27 -07:00

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 (37) are cosmetic.