Package and run as a runnable JAR; handle external file paths for levels outside the IDE
About the free online course
Turn Java fundamentals into a complete, playable tower defense game by building a project that feels like a real product, not a throwaway demo. In this free online course, you will create a grid-based game using Java and Swing, learning how to organize code so it stays maintainable as features grow. Instead of focusing on isolated snippets, you will work through the practical decisions every game developer faces: rendering sprites smoothly, reacting to player input accurately, and keeping the experience consistent across different machines.
You will develop a solid game foundation with a reliable loop structure and clean scene handling, so menus, settings, editing, and gameplay behave predictably. Along the way, you will tackle common problems that trip up new developers, such as coordinate offsets with mouse input, drawing and rotating sprites correctly, and animating tiles without creating messy, duplicated asset definitions. By working directly with a tile grid, you will see how data structures and rendering logic connect, which makes your project easier to extend.
A major milestone is bringing the world to life with enemies that follow paths across the map. You will implement and refine path logic so movement and turns look correct, while keeping positions precise for smooth motion. From there, you will add towers with placement rules, prevent invalid or overlapping builds, and create combat interactions that feel responsive. Projectiles, range indicators, damage, health bars, explosions, and slow effects are introduced in a way that highlights reusable architecture rather than one-off hacks.
To make the game feel complete, you will add wave progression, an economy with income and spending choices, upgrades and selling logic, pause and game-over behavior, and sensible replay handling. You will also implement saving and loading levels and learn what changes are needed to package and run the game outside the IDE. By the end, you will have a working Java tower defense game and the confidence to evolve it into your own original version with new enemies, towers, levels, and balancing.
Course content
Video class: Java Game Development TUTORIAL - Episode #0118m
Exercise: Which method must you override in a JPanel to render shapes or sprites for a Java Tower Defence game?
Video class: Java Game Development TUTORIAL - Episode #02 - IMAGES27m
Exercise: What window size should you set to display a 20 by 20 grid when each sprite is 32 by 32 pixels?
Video class: Java Game Development TUTORIAL - Episode #03 - the GAME LOOP32m
Exercise: In the tower defense game's loop setup, what target Updates Per Second (UPS) ensured consistent game speed?
Video class: Java Game Development TUTORIAL - Episode #04 - INPUTS32m
Exercise: How should the game manage and render Menu, Playing, and Settings scenes?
Video class: Java Game Development TUTORIAL - Episode #05 - LEVEL EDITOR20m
Exercise: Which component provides the 2D grid of tile IDs used to render the level?
Video class: Java Game Development TUTORIAL - Episode #06 - Custom Buttons!30m
Exercise: Fixing inaccurate mouse coordinates in the Swing game menu
Video class: Java Game Development TUTORIAL - Episode #07 - Bottom Bar PART 1/223m
Exercise: Routing mouse events to the bottom bar in the Java Tower Defense UI
Video class: Java Game Development TUTORIAL - Episode #07 - PART 2/226m
Exercise: How do you make the selected tile preview snap to the 32x32 grid while moving the mouse in the Java Tower Defense editor?
Video class: Java Game Development TUTORIAL - Episode #08 - LOAD, SAVE and CREATE files - PART 1 / 216m
Exercise: What is the correct length of the 1D int array to save a 20x20 tile level?
Video class: Java Game Development TUTORIAL - Episode #08 - LOAD, SAVE and CREATE files - PART 2 / 219m
Exercise: Why switch from sc.nextInt to Integer.parseInt(sc.nextLine) when reading level tile IDs?
Video class: Java Game Development TUTORIAL - Episode #09 - The EDIT Scene29m
Exercise: Displaying the level in the Editing scene
Video class: Java Game Development TUTORIAL - Episode #10 MORE SPRITES25m
Exercise: How do you rotate only the second layer when building a composite sprite from two images?
Video class: Java Game Development TUTORIAL - Episode #11 - ROTATION!32m
Exercise: Which UI approach was implemented to handle rotated tiles in the level editor?
Video class: Java Game Development TUTORIAL - Episode #12 - ANIMATIONS24m
Exercise: Which approach adds water tile animation with minimal code changes and no tile list bloat?
Video class: Java Game Development TUTORIAL - Episode #13 - ENEMY18m
Exercise: Why are enemy positions stored as floats in the Java Tower Defence game?
Video class: Java Game Development TUTORIAL - Episode #14 - Pathfinding37m
Exercise: In the Java Tower Defence pathfinding, what change ensured correct turns at corners when the enemy hit a grass edge?
Video class: Java Game Development TUTORIAL - Episode #15 - More Enemies23m
Exercise: Handling enemy initial direction for pathfinding
Video class: Java Game Development TUTORIAL - Episode #16 - Finishing Pathfinding20m
Exercise: Where can you place the start and end path points in the editor?
Video class: Java Game Development TUTORIAL - Episode #17 - Towers - Part #113m
Exercise: Where should tower sprite images be stored and loaded in the game's architecture?
Video class: Java Game Development TUTORIAL - Episode #18 - Towers - Part #218m
Exercise: How is tower placement restricted to valid tiles in the Java Tower Defence game?
Video class: Java Game Development TUTORIAL - Episode #19 - Towers - Part #316m
Exercise: How is tower placement blocked on an occupied tile?
Video class: Java Game Development TUTORIAL - Episode #20 - Combat - Part #114m
Exercise: Which properties should each tower define to enable basic combat functionality?
Video class: Java Game Development TUTORIAL - Episode #21 - Combat - Part #213m
Exercise: In a Java Tower Defense game, how should you compute the enemy health bar width so it shrinks with damage?
Video class: Java Game Development TUTORIAL - Episode #22 - Combat - Part #315m
Exercise: Why should the tower range circle be drawn with width and height doubled?
Video class: Java Game Development TUTORIAL - Episode #23 - Deadly Projectiles!26m
Exercise: How are projectile xSpeed and ySpeed calculated to aim toward an enemy at any angle?
Video class: Java Game Development TUTORIAL - Episode #24 - Mastering the Matrix!13m
Video class: Java Game Development TUTORIAL - Episode #25 - Explosions!25m
Exercise: Implementing AOE bomb damage and explosion handling
Video class: Java Game Development TUTORIAL - Episode #26 - Freeze!09m
Exercise: How is a temporary slow effect and its visual indicator best implemented for enemies in a Java Tower Defense game?
Video class: Java Game Development TUTORIAL - Episode #27 - Waves!19m
Exercise: In the wave system, what is the simplest way to represent a wave's enemies for spawning?
Video class: LEARN HOW TO make a GAME - TOWER DEFENCE in JAVA - 202100m
Exercise: What is typically the first step when starting the Java tower defense game project?
Video class: Java Game Development TUTORIAL - Episode #28 - ENDLESS of WAVES28m
Exercise: Transitioning to the next wave in a Java Tower Defense game
Video class: Java Game Development TUTORIAL - Episode #29 - MONEY!27m
Exercise: How is passive gold generation implemented in the Java tower defense economy
Video class: Java Game Development TUTORIAL - Episode #30 - SELL and UPGRADE towers!30m
Exercise: When selling an upgraded tower, how is the gold refund calculated?
Video class: Java Game Development TUTORIAL - Episode #31 - Game Paused!12m
Exercise: How should the Pause button toggle the game state in the Java Tower Defense game?
Video class: Java Game Development TUTORIAL - Episode #32 - GAME OVER!29m
Exercise: What is the correct way to implement Replay after Game Over in a Java Tower Defense game
Video class: Java Game Development TUTORIAL - THE END!06m
Exercise: Preventing Immediate Wave Spawn in Java Tower Defense
Video class: Java Game Development TUTORIAL - BONUS #0106m
Exercise: Reusing Projectiles to Prevent List Growth
Video class: Pathfinding 2.0 - BONUS Episode #02 - Java Game Development47m
Exercise: In a Java tower defense game, what is the main advantage of precomputing a road direction array for pathfinding?
Video class: How To Make a Runnable Jar in Eclipse for Java - Bonus #314m
Exercise: Running the Tower Defence game outside the IDE: how should you handle the level file path?