Java Game Development Tutorial
Tower Defence
Welcome to the Java Game Development Tutorial. Tower defence games are a great start to begin your game dev journey. They contain stuff such as:
Animations
Gameloop
Pathfindings
Event Handling
Rendering
and much more
And we will learn all of this in this tutorial. We will implement the most basic way to solve a problem and then work our way up from that to make it better.
All of the code and resources will be listed below.
Episode 01
In this first episode we start by setting up all the tools.
We make our first window and draw something onto it.
Episode 02
in this episode we create a grid of colors and slowly move towards adding sprites and ends up making a grid of Sprites.
Episode 03
We learn what a game loop is and various ways of implementing it.
Episode 04
Inputs and game state. How it all is connected.
Episode 05
Now we added a way of building the level. The simplest way of doing it of course.
Episode 06
Making our own buttons.
Episode 07
This contains the code for episode 7 part one AND two.
We make it way easier to change tiles instead of looking into an int array
Episode 08
We finally learn how to save, load and also create files the simple way. Code is for both part one AND two here.
Episode 09
Adding a proper edit scene and we move a lot of code around to make it all work.
Episode 10
We are finally adding more sprites. We are also doing so with code?
Episode 11
Adding the rest of the sprites and make it so we can rotate our sprites.
Episode 12
Finally, we are adding sprites to our game.
Episode 13
We are adding enemies! First of a few episodes that will contain this subject.
Episode 14
Today we create a pathfinder for our Enemy.
Episode 15
We add all the enemies and work on making our pathfinding better with start- and endpoints.
The code in this zip file contains the code for next episode as well. Episode 16.
Episode 16
We continue from last episode. Adding more functionality to our pathfinder.
Same code as episode 15
Episode 17
This will be the start of our tower work. We create our first tower in this episode.
Part 1.
Episode 18
We continue our work with the towers. Adding buttons etc.
Part 2.
Episode 19
In this one, we make our towers clickable and also, disable the ability to place a tower on top of another tower.
Episode 20
First part of the combat section of our game.
Fixing some stuff from last episode and also adding the variables and values we will need later.
Episode 21
In this episode we continue our work for the combat system. Also adding a tower range visual
Episode 22
Today we add the range check and also begin with our projectiles.
Episode 23
In this episode we make our turrets target our enemies no matter what direction they are at, and we add damage to the projectiles.
Episode 24
We talk about how to rotate and translate, and why we need them both for a successful rotation.
Episode 25
In this episode we add explosions and change some constant values.
Episode 26
Last episode for a while about towers. Lets finish this off with the slow effect by the wizard. What will come next ?
Episode 27
In this episode we add enemies in waves. Starting to look like a real TD game now!
Episode 28
More than just one wave, and they are coming! Also adding some status test about the current wave of the enemies.
Episode 29
Today we add the economy. Gold income and cost for towers are added. Good luck!
Episode 30
We finish what we started last episode. Now we can sell and upgrade towers.
Episode 31 & Episode 32
Adding pause button to our game. Now the player can take a break if needed! In the other episode, we added game over scene.
There is two episodes in the same zip file. But two videos.
Episode - Completed
This is the completed version of the game. You will still need to change the values for health, speed, damage and such.
You will also set the amount of waves you want as well as the amount of enemies in each wave.
I also added a fix that needed to addressed. You will also need a name for the game.
Download Episode - Completed.zip
Bonus Episode 1
Adding an quick method to reuse the inactive projectiles of our game.
Bonus Episode 2
This is about a different kind of pathfinding. Scales better than our current. Both got different use cases. Pick whichever you like.
Note:
Worth knowing. I added a - return; after we killed off the enemy in case we were at the end. No point of continuing after that. I also moved the check:
if(isTilesTheSame(newTile, end)) {
e.kill();
playing.removeOneLife();
return;
}
Inside the check for isTheTilesTheSame(curr,newTile);
No need to check for end tile if the tile never changed.
Download Bonus Episode 2.zip
Bonus Episode 3
Hey.
The last bonus episode for this tutorial. Finishing off by learning how to play the game outside eclipse.