How to build a tower defense flash game (Intro)

This is an on-going series in creating tower defense game – If you have any concerns or questions please send me feedback – This is what we’ve created so far, learn how to make this and more:

We are currently up to Part 10 – Let me know what you think by posting a comment or spreading the word about the site :)

How to build a tower defense flash game – Part 10 – Win or Lose!





How to build a tower defense flash game – Part 1 Waypoints and Enemies

How to build a tower defense flash game – Part 2 Placing Towers

How to build a tower defense flash game – Part 3 Rotation and Realism

How to build a tower defense flash game – Part 4 Starting the tower attack!

How to build a tower defense flash game – Part 5 – Wave after Wave of Creep Kill’in!

How to build a tower defense flash game – Part 6 – Tower Powers!

How to build a tower defense flash game – Part 7 – Gold and Upgrades!

How to build a tower defense flash game – Part 8 – Poison Tower and Basic Startup!

How to build a tower defense flash game – Part 9 – Scores and Wave Timeline!

Intro
If you’re like me you have an unusual fascination with tower defense games – I say unusual, because the design of a tower defense game is so damn simple that I often times wonder why I like them so much.

(Note: for those who may have stopped by and are wondering “what is this tower defense thing he is going on about”. I present you this mini-description)

Tower Defense Description

  • The enemy starts at one side of a map and travels along a path towards a destination ( usually on the opposite side of the map).
  • You create towers along these paths that fire on the enemy while they pass by.
  • Attempt to survive wave after wave of stronger and stronger enemies by upgrading your towers with more powerful abilities.
  • Either win the game by beating the final wave (usually 40 or 50) or keep going till you lose and there by get bragging rights when you die at wave 97.

In my humble opinion there is not a casual game that better defines casual, then a tower defense game. The artificial intelligence is seemingly so basic and yet the games are often not beatable the first time around until you get a feel for it. The time flys by as you tab between windows in “Firefox” or “IE” to see how the battle is going and occasionally upgrading or building new towers when necessary. Who hasn’t played a tower defense game and lost on the 48th level of a 50 level game, because you didn’t plan for multiple types of enemies to attack at the same time.

You may wonder why this is at all important in the creation of a tower defense game? The reason I feel that this is important is that I HAVE played tower defense games that haven’t been so great. So if I’m gonna teach this, I want people to make games that I find enjoyable. There is nothing more frustrating than making a product with all the bells and whistles and finding out it’s not enjoyable to play. So here is what I think are qualities that are important to a tower defense game.

  • The game shouldn’t rush the player, but additional “score” should be given to those who plan quickly
  • No resource management of any kind – This means that you always know how much damage your tower does AND you don’t need to “build” specific tower upgrades to unlock the upgrades of a tower.
  • tower formation and strategy is key – The shape of the map and how much room to build towers should be taken seriously. If all you need to build is one type of tower to beat a game whats’ the fun in that?
  • Ending are great (if you have some bad ass boss on level 50), but so are never ending ones where you can compare your game with other people. However, which one to choose is based solely on how you design your map and the tower upgrades you give.
  • MOST IMPORTANTLY: Don’t go upgrade crazy with your towers. Just because you can create a lazer/triple damage/slow tower, doesn’t mean you should. I’ve found the TD games I like the most have towers that handle one function and do it well. There are always exceptions, but they are few and far between.

I’m going to start to list out the parts on this introduction as I write them and above all I intend to finish this tutorial. What we will have at the end of this will hopefully something special and maybe you’ll learn something along the way.

Anyway on to the show –
How to build a tower defense flash game – Part 1 Waypoints and Enemies

How to build a tower defense flash game – Part 2 Placing Towers

How to build a tower defense flash game – Part 3 Rotation and Realism

How to build a tower defense flash game – Part 4 Starting the tower attack!

How to build a tower defense flash game – Part 5 – Wave after Wave of Creep Kill’in!

How to build a tower defense flash game – Part 6 – Tower Powers!

How to build a tower defense flash game – Part 7 – Gold and Upgrades!

How to build a tower defense flash game – Part 8 – Poison Tower and Basic Startup!

Click here for a other articles in the article section.

Posted on Feb 19, 10:58 PM by Walter Reid

what progam did you use to create this tower defence game.

k | Feb 14, 05:41 PM | #

It’s Adobe Flash CS4 proffesional i believe, that’s the one i’m using and it works fine with me. Btw, i’m looking forward out to tomorrow for part 9 !!

Tijs | Feb 17, 12:23 PM | #

WOW! this is amazing!
I haven’t seen the eariler parts yet so im going to look at them now! Keep up the GOOD WORK!

Lawrence | Feb 18, 05:05 AM | #

I appreciate the compliment – Let me know if there is anything you specifically think I should cover in the next part.

Walter Reid | Feb 18, 05:42 AM | #

a main menu perhaps?

Tijs | Feb 18, 07:13 AM | #

And a winning & losing condition. Beaten the game with a score of 522501.
Looking forward to the next part!
Btw, your remember button doesn’t work quite well for me.

Tijs | Feb 18, 07:25 AM | #

Great idea guys – I found a pseduo bug in Part 9 – There should infact be a winning condition, but it isn’t coming in. I will add a quick Part 10 either today or tomorrow to handle “win/loss” and health to the mix. It’s already done I just need to explain it.

Walter Reid | Feb 18, 10:42 AM | #

good tutorial….thanks

shirotsu | Feb 19, 04:27 PM | #

is that all:)?
I wanna ask what is the code if an enemy suffer a stop…

motoab | Feb 20, 05:27 AM | #

MOTOAB: Do you mean the tower power when an enemy is slowed down? If you do mean that then I discussed that power in Part 6. I never went over “stop” power, but it would n’t be too hard to implement.

Walter Reid | Feb 20, 07:46 AM | #

Great Tutorials, I’ve ended up with a game that looks completley different and i’ve also changed the prices of towers. Anyway i think changing the look of towers slightly when they are upgraded would be a good addition for an upcoming part. Thanks for the tutorial it has helped me a lot. Good work.

Jonnymint | Feb 20, 06:55 PM | #

Excellent – If you have the time, send me a link to the game, it would be excellent to see what you accomplished. I’m glad this was helpful.

Walter Reid | Feb 21, 12:07 AM | #

Thank you very much:),
Walter Reid. I have followed your tutorials from part 1 to here:). I can almost do it. It’s really helpful for us to get start! You’re super great XD!

motoab | Feb 21, 03:31 AM | #

You’re making a great game here.

I have just one suggestion:
I think the towers should aquire a target on a ‘per shot’ basis, rather than ‘out of range/dead’ basis.

More often than not, you’ll want a tower to “intelligently” switch target.
For example, at the top left of the buildable area, towers can see the creeps twice.
You’d want your towers to focus on the ones that are about to get away, rather than carry on killing one freshly spawned.

Does that make sense?
You might also consider targetting options such as “Lowest/Highest Health”, “Oldest/Youngest”, “Closest/Furthest”, and maybe even “Unpoisoned/Unslowed”.

Just my 2pence.

Emma | Feb 22, 07:50 PM | #

Can you make it so you can buy health it would make it better

William Ryan | Feb 23, 07:32 PM | #

Hey great tutorial. How do I animate the towers when there a creep in range?

Jing Yu | Mar 21, 12:35 AM | #

What action script did you use? I’m using as2 and it doesn’t work. I try to fix it and the same errors keeps appearing.

Tagori | Mar 24, 12:09 PM | #

Hello Mr. Reid,

I am following along in your tutorial, one of the best I’ve seen. You have many ideas similar to how I was considering doing things, and some a bit different. I am going to try to get at leat one chapter each day. I have my basic resources together, and I have completed part 1. I am making some modifications as I go. I will share some of my notes with you when Im done. It really helps to see all of the components laid out in order, to act as a roadmap. I downloaded part 10 to act as a reference as I follow along the tutorial. Thanks for putting this together, it’s really pretty cool. Im using Flash 8 Pro btw. Im hoping to have a good prototype done soon.

sincerely,
lord_midnight

lord_midnight | May 29, 09:52 AM | #

Add Your Comment

You may use textile in your comment.

How To Build a Tower Defense Flash Game – Part 10 Win or Lose

Posted on Feb 19, 08:41 PM by Walter Reid

Ok, so based on the comments I realized that not having a “win” or “lose” condition at this point was not working. Well, fear not my friends, I have fixed the situation and now you can lose or win depending on how you play the game now. Yay!

Here is the latest tower defense game that you can now build…





How To Build a Tower Defence Flash Game – Part 9 Scores and Wave Timeline

Posted on Feb 17, 09:05 PM by Walter Reid

Welcome to another installment of my tower defense series – Part 9. I know you’ve been asking for more and I’ve done my best to get creative. I’ve already built out the next few Parts the only thing I need to do now is explain it all, but for now without any more delay – This lesson we will be covering the following subjects…

How to build a tower defense flash game (Part 8 - Poison Tower and Basic Startup)

Posted on Jan 20, 08:30 PM by Walter Reid

We are now at Part 8! You should be pretty up on your tower defense games at this point in the series. However, before we begin you should make sure you have reviewed the previous tutorials if you came here directly from a link.

How to build a tower defense flash game (Part 7 - Money and Upgrades!)

Posted on Jan 9, 03:26 PM by Walter Reid

You can’t get something for nothing. That’s what my family always said, so why should tower defense games be any different. You need to make people work for it. That means you need to pay your towers for hire and the better the towers, the more they should cost. Don’t worry we won’t make anything too expensive, but keep in mind that this is “level balancing” and it is a hugely important step…

How to build a tower defense flash game (Part 6 - Tower Powers!)

Posted on Dec 17, 10:28 PM by Walter Reid

Wow, the last article was intense – How can I possibly beat that? Oh, I think I can come up with an idea, um, how about tower powers?! You know that thing that makes the towers placed unique. Well I could think of a few powers that can be combined to make virtually all tower types – but then i realized something so complete would take a lot of writing to explain. So here are the intermediate level tower powers!

How to build a tower defense flash game (Part 5 - Wave after Wave of Creep Kill'in)

Posted on Dec 16, 12:00 PM by Walter Reid

Each creep has an increasing number of hit points after each wave, starting at 40 and going up to the final boss on wave 6 at 6000. Don’t worry I didn’t limit you with the burden of money yet, so you should have no problems. Just place as many towers as you need to get the job done!

How to build a tower defense flash game (Part 4 - Starting the tower attack)

Posted on Dec 14, 01:41 PM by Walter Reid

Today we are going to charge right into the newest section in the series – “Starting the tower attack!” This is one of the most important components in a tower defense game and will ultimately be one of the most enjoyable to program. I will definitely not get to all the cooler aspects of attacking towers in this one section, but I promise that we will create all sorts of fun towers soon. You will however, at the end of this particular tutorial, have enough knowledge to make any cool towers you can think of.

How to build a tower defense flash game (Part 3 - Rotation and Realism)

Posted on Dec 10, 07:31 AM by Walter Reid

Welcome to part 3 of the tower defense series – Today we are going to be delving into the fine art of realism. Nothing ruins the immersion of games like something that doesn’t make sense in the real world (unless that’s what your game is completely about. Since most tower defense games are rooted in the real world, we ned to make sure that the items in the game act like real object.

How to build a tower defense flash game (Part 2 - Placing Towers)

Posted on Dec 7, 11:12 PM by Walter Reid

Welcome to part 2 of the tower defense series – Today we’re going to be adding code to place towers. Whoa, slow down there you say – “place towers? That’s crazy talk”. I assure you it isn’t and once you are able to place towers in the next section we will combine our lessons together to have a single level of play!

How to build a tower defense flash game (Part 1 - Waypoints and Enemies)

Posted on Dec 5, 11:44 AM by Walter Reid

I am going to going to show you how to have a basic enemy follow a predefined path, by following a series of waypoints. By the end of this series, you will have all the information to be well on your way to making the next great tower defense game.