Tower Defense: a Greenfoot project

Tower Defense

Greenfoot project 8 · all projects · part of Intro to Java with Greenfoot · not graded, and not tracked as progress

Enemies that follow a path, towers you place, and targeting that picks what to shoot.

Before you start: finish lesson 4.5. That is the last thing this project needs. Starting earlier is allowed and you will hit a method nobody has shown you yet.

Part 1. Put this window on one side of your screen and Greenfoot on the other, then build along with it.

Part 2. Put this window on one side of your screen and Greenfoot on the other, then build along with it.

Methods you will use

Every one of these appears in the build. The lesson number is where the course teaches it, so if a row looks unfamiliar you have not missed anything, you just have not got there yet.

Method Taught in What it does here
getObjects(Enemy.class) 4.5 every enemy currently alive
for (Enemy e : enemies) 4.6 check them all
private int health 3.8 towers and enemies both remember things
removeObject(e) 3.7 kill one

Not covered by the course

This project uses these, and the lessons never get to them. That is not a gap in your knowledge. Copy them from the video, or ask.

Method Why it is here
getObjectsInRange(int radius, Class) a tower picking a target it can actually reach.
Greenfoot.mouseClicked(null) placing a tower where you click.
turnTowards(int x, int y) a turret facing what it shoots.

Get in Touch

Whether you're a student, parent, or teacher — I'd love to hear from you.

Just want free AP CS resources?

Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]