Jump to content


Photo
* * * * * 3 votes

Tower Defense Game Tutorial


  • Please log in to reply
111 replies to this topic

#31 joffysloffy

joffysloffy

    GMC Member

  • GMC Member
  • 21 posts

Posted 03 January 2009 - 01:39 PM

Great tutorial!

In some posts before, I saw that a few people tried to reach the highest, reachable wave. Now with the new up-grade system, I tried that too and I reached wave 220 ^_^!
Max_level_TD_tutorial.bmp (1.2 MB)

I actually found some flaws in the tutorial with the depth. The bullets should have a lower depth, because they are underneath the towers, which looks really weird. And sometimes the laser of the lasertower gets underneath another lasertower, so that also looks really weird, but I think I have found a way you can solve that. Just check the distance to its target and multiply that by -1. So if a tower is next to the path and a tower is behind that one. Then the tower behind the tower that is next to the path will have a lower depth than that tower, so its laser will be on top of the tower that is next to the path.
I hope you hear what I am saying ^_^.

Joffysloffy.

Edited by joffysloffy, 03 January 2009 - 04:14 PM.

  • 0

#32 athanatos

athanatos

    GMC Member

  • New Member
  • 25 posts

Posted 17 February 2009 - 10:42 PM

Hello everyone, I'm sorry I haven't answered the replies earlier, but I'm no longer making games. That also means I'm not checking this forum anymore. I can, however, still answer questions about GM that have to do with TD games, but in that case you better PM me. I'm not sure if I'll visit the forum another time, unless I get a PM.
I'll answer the questions posted above.

Is it O.K if I use some of these codes (Altered a bit) in a game that I might sell if I put you (athanatos) in the credits?

Sure.

I have one question; I just made some more towers, but whenever I try to click on the placed tower (to open the little menu, to upgrade / sell them), the menu doesn't show up, but the circle around the tower does.

What's the problem with this?

The circle is drawn by the tower itself. But the menu stats are drawn by the controller. It might be possible that the 'ii_select' variable isn't set when you select the tower, since the tower stats, and the other buttons are only drawn if this variable is set correctly.

I actually found some flaws in the tutorial with the depth. The bullets should have a lower depth, because they are underneath the towers, which looks really weird. And sometimes the laser of the lasertower gets underneath another lasertower, so that also looks really weird, but I think I have found a way you can solve that. Just check the distance to its target and multiply that by -1. So if a tower is next to the path and a tower is behind that one. Then the tower behind the tower that is next to the path will have a lower depth than that tower, so its laser will be on top of the tower that is next to the path.
I hope you hear what I am saying tongue.gif.

You're right. That should do the trick. But the depth of the tower must be reset to its original value afterwards, and objects that might fly over the tower, like bullets or missiles, should have a much higher depth value (like 800 or 1000) or the tower will be drawn above them.
  • 0

#33 DarkLopo

DarkLopo

    GMC Elite

  • GMC Member
  • 874 posts

Posted 20 February 2009 - 01:43 PM

:lol:
___________________________________________
ERROR in
action number 1
of Step Event
for object btn_upgrade:

Error in code at line 4:
if controller.ii_select = noone

at position 20: Unknown variable ii_select

What to do? I did same things than you, but in the example it works, but in my game it doesnt.

Ps really nice game, 10/10 on tutorial : )) but could you help me? Same happens at btn_sell... : (
  • 0

#34 DarkLopo

DarkLopo

    GMC Elite

  • GMC Member
  • 874 posts

Posted 20 February 2009 - 01:46 PM

:(
___________________________________________
ERROR in
action number 1
of Step Event
for object btn_upgrade:

Error in code at line 4:
if controller.ii_select = noone

at position 20: Unknown variable ii_select

What to do? I did same things than you, but in the example it works, but in my game it doesnt.

Ps really nice game, 10/10 on tutorial : )) but could you help me? Same happens at btn_sell... : (


Problem fixed, forgot to add controller in room :lol:
  • 0

#35 Hardly

Hardly

    GMC Member

  • New Member
  • 40 posts

Posted 20 February 2009 - 05:23 PM

What do you say about people getting those codes and changing them?

I mean, about using your example as a base for a much higher detailed game.

I would give credit for sure
  • 0

#36 fligamaflogamus

fligamaflogamus

    GMC Member

  • GMC Member
  • 60 posts

Posted 25 February 2009 - 01:37 PM

Great tutorial!

Although I cant seem to understand how the enemy speed is being controlled.
I want to create a tower that fires blobs that slows the enemy it comes into contacts with, how would i do this?

Im using the free version of gamemaker 7
  • 0

#37 athanatos

athanatos

    GMC Member

  • New Member
  • 25 posts

Posted 28 February 2009 - 03:05 PM

What do you say about people getting those codes and changing them?

I mean, about using your example as a base for a much higher detailed game.

I would give credit for sure

If you give me credit, then it's okay to use it, even in a competition game (unless it's just a rip-off from this tutorial, it must be your own game).

Great tutorial!

Although I cant seem to understand how the enemy speed is being controlled.
I want to create a tower that fires blobs that slows the enemy it comes into contacts with, how would i do this?

Im using the free version of gamemaker 7

That's got to do with the path speed. The enemies don't have any 'speed'. If you want to change the speed with which they move through the path, you need to change the 'path_speed' variable.
  • 0

#38 fluidic ice

fluidic ice

    GMC Member

  • GMC Member
  • 812 posts
  • Version:GM:Studio

Posted 01 March 2009 - 12:55 AM

Haha! New Record, Beat this:
Posted Image
Yep i'm addicted too :P

I don't know how i could use this in my TDS, but I could make it into an automatic turret. . . . .

Nice Example though!

Edited by fluidic ice, 01 March 2009 - 12:58 AM.

  • 0

#39 DJ J4KE

DJ J4KE

    GMC Member

  • GMC Member
  • 142 posts

Posted 02 March 2009 - 04:36 PM

I've created a new type of enemy, How do I make it so that only that enemy can spawn in that room? All the enemies are spawning and I only want that particular one!

I have GM7 lite.
  • 0

#40 athanatos

athanatos

    GMC Member

  • New Member
  • 25 posts

Posted 07 March 2009 - 03:33 PM

I've created a new type of enemy, How do I make it so that only that enemy can spawn in that room? All the enemies are spawning and I only want that particular one!

I have GM7 lite.


You mean that you want the new enemy only to be created in a particular room, while the amount of enemies to be created remains the same? Then you could write this (in the script 'get_wave_enemies'):
//Create enemies if needed for every array
	if wave_time < 600 wave_time += 1;
	if wave_enemies > 0
	{
		if wave_time = (ee-wave_enemies)*15+15
		{
			if (room == <the new room>)  instance_create(-32,0,<new enemy));
			else instance_create(-32,0,<old enemy));
			wave_enemies -= 1;
		}   
	}
instead of the code that was below "//Create enemies if needed for every array". If all enemies were created instead of this one, you probably forgot to use the 'else'-statement.
  • 0

#41 UltimateGaming

UltimateGaming

    GMC Member

  • New Member
  • 121 posts

Posted 08 March 2009 - 11:43 AM

nice tut...i got to wave 534...i had it minimised and forgot i was playing...

anyway...i changeed the highest level of each tower to 100...when they got there they were doing 9459358(something like that) damage...lol
  • 0

#42 morbis

morbis

    GMC Member

  • New Member
  • 4 posts

Posted 19 March 2009 - 11:13 PM

This is a great tutorial! I was wondering if you could throw in a pro one where the turrets aim towards the enemies.
  • 0

#43 funlerz

funlerz

    GMC Member

  • New Member
  • 113 posts

Posted 20 May 2009 - 02:03 PM

please add a mirror, the main download on the page doesnt load the download for me, and metalink download starts downloading but cant find the program.

Edited by funlerz, 21 May 2009 - 11:59 AM.

  • 0

#44 razourik

razourik

    GMC Member

  • GMC Member
  • 1871 posts
  • Version:Unknown

Posted 30 May 2009 - 11:31 PM

This is an excellent tower defense engine! ;) I just wish that there was a button you could press to release the next wave, and if possible also a code that makes the new wave's enemies have the next enemy subimage so that all the waves wouldnt look the same. But other than that, great job!
EDIT: How do I make the small explosions get created when the laser hits the enemy? ^_^

This is a great tutorial! I was wondering if you could throw in a pro one where the turrets aim towards the enemies.


That could be easily done in unregistered too...

Edited by razourik, 31 May 2009 - 11:45 PM.

  • 0

#45 Manuel542

Manuel542

    GMC Member

  • New Member
  • 9 posts

Posted 11 June 2009 - 02:02 PM

Thank you so much i learned alot from this! :) :D B)
  • 0

#46 razourik

razourik

    GMC Member

  • GMC Member
  • 1871 posts
  • Version:Unknown

Posted 14 June 2009 - 11:45 PM

This is the amount of progress I've made on the td tut to make my own game: ;)
Razourik's TD tut
Check it out, theres lots of things to be learned from it that werent in the original tut. :P
  • 0

#47 RedSoxFan

RedSoxFan

    GMC Member

  • New Member
  • 42 posts

Posted 24 June 2009 - 03:44 PM

Awesome Tutorial!
Can you explain to me how to create these 2 features?
1. when the user presses say the delete key the tower selected from the menu that hasn't been placed yet will be destroyed and the price of the tower will go back into money.

2. stun the enemy for 5 sec then go back to normal speed without getting off the path.

Thanks
RedSoxFan

EDIT: Nevermind fiqured it out

Edited by RedSoxFan, 24 June 2009 - 11:10 PM.

  • 0

#48 Kubanen

Kubanen

    Vipers

  • GMC Member
  • 1723 posts

Posted 24 June 2009 - 03:53 PM

Awesome Tutorial!
Can you explain to me how to create these 2 features?
1. when the user presses say the delete key the tower selected from the menu that hasn't been placed yet will be destroyed and the price of the tower will go back into money.

2. stun the enemy for 5 sec then go back to normal speed without getting off the path.

Thanks
RedSoxFan

ask in novice?
  • 0

#49 buzzy

buzzy

    GMC Member

  • New Member
  • 6 posts

Posted 06 July 2009 - 09:21 AM

Your tutorial is VERY COOL! :blink:
This is really good, and I will give you credit for the game, but i need some help.

How do you make enemy waves different,
for example 12 bombs come on wave 1 and wave 2 30 bombs and 15 blue bombs come and on wave 100, about 1000 rainbow bombs, 500 yellow bombs, and so on.
How do you have multi-enemy waves?

How do you make flame tower fire like using the particle function. It shoots out fire rapidly.
How do you make a ice blower tower. I make a single ice particle sprite and make it into a blower which blows lots of ice particles. It is still but targets bombs.

How do you make a tower rotate in the enemies direction?
How do you make a tower shoot; not one enemy but lots. When i put different types like red, blue, yellow, rainbow, white bombs, they only get the red bomb?? I want them to target every single type.

How do you make spikes. You can only place them on the path and they do not fire. They stay there and destroys upto 10 bombs and then it's gone.
A different upgrade system; like instead of upgrading to lvl 1 and all that, you could upgrade to example: "FROST TOWER" upgrade to PERMA FROST or FAST FIRING or FROST BOMBS?
Instead of a wave counter, could you have no, just a start round button? When a whole wave is finished, the start round button appears.
When your mouse hovers a button like THE FROST TOWER, a description appears like FROST TOWER, includes power and rate of fire.
A booster. If you place them near towers, they increase the surronding towers (in it's radius) power.
Bombs multiplying. If a black bomb is destroyed, if a blue bomb is destroyed, a black bomb appears just like in bloons tower defense how a blue bloon pops into a red bloon.
Screen clear function: If you click on like blackhole, a blackhole will appear in the center of the screen and suck up lots of bombs for 10 seconds.
Or if you activate "Atom BOMB" it clears the whole screen.

Grenade thrower. If bombs come, it starts spinning really fast shooting out 1 grenade every 2 millisecond at the enemy. But the grenades are very weak.

Immunities, like if you place an ICE BLOWER, it doesn't effect an ice bomb or if you place a FLAME TOWER it doesn't effect Fire bombs.

4 direction shooters. If you place one of these, it will shoot in all 4 directions at the enemy. good in corners.

How do you do all that? I tried, it didn't work.

Edited by buzzy, 06 July 2009 - 09:29 AM.

  • 0

#50 buzzy

buzzy

    GMC Member

  • New Member
  • 6 posts

Posted 07 July 2009 - 05:18 AM

How do I make the small explosions get created when the laser hits the enemy?


OK. To make small explosions appear when the laser hits the enemy, you need a explosion sprite. If your LASER projectile is an object, in "Collision with enemy" event add the Destroy the instance to enemy. And add another event " DESTROY" and then add in Create Instance of explosion 0, 0, relative, but you will need an explosion object. And then add Animation End into the event FOR the explosion and then add destroy the instance to SELF. ;) I hope this helps you!
  • 0

#51 JaJoentertainment

JaJoentertainment

    GMC Member

  • New Member
  • 2 posts

Posted 06 September 2009 - 07:26 PM

Hey i was wonderin how to make it so the towers aim at the enemies like they do in your amazing interceptor game? any help?
  • 0

#52 JaJoentertainment

JaJoentertainment

    GMC Member

  • New Member
  • 2 posts

Posted 07 September 2009 - 06:06 PM

This is an excellent tower defense engine! :) I just wish that there was a button you could press to release the next wave, and if possible also a code that makes the new wave's enemies have the next enemy subimage so that all the waves wouldnt look the same. But other than that, great job!
EDIT: How do I make the small explosions get created when the laser hits the enemy? :GM6:

This is a great tutorial! I was wondering if you could throw in a pro one where the turrets aim towards the enemies.


That could be easily done in unregistered too...

how do you make the towers aim towards the enemies then?
  • 0

#53 Davidramsey03

Davidramsey03

    GMC Member

  • New Member
  • 8 posts

Posted 29 September 2009 - 11:25 PM

Hi. This is a wonderful tutorial....
I've been following and making the changes I'm looking for to my game.
I've got a couple questions for a couple of my modifications.

1. Some of the newer tower defense games are "free-style", where there is a start point and an end point, and the enemies find their own way to the end point based on the way you place the towers in their path...
So, I'm looking for some method of pathfinding, while avoiding the objects I place... BUT, in my tests, the "Step Towards Point while avoiding" pre-made function gets confused pretty easy. Any ideas?

2. Along with the first issue, I want to stop you from placing a tower in a position that would block the only path to the end, i.e. a check to make sure there is still a valid path before allowing you to place the tower there.

ANY HELP WOULD BE MUCH APPRECIATED!

Thanks
  • 0

#54 12warr12

12warr12

    GMC Member

  • GMC Member
  • 681 posts
  • Version:Unknown

Posted 30 October 2009 - 03:41 PM

10/10

I just don't know how to make new towers and add them to the menu
  • 0

#55 Sonicdog999

Sonicdog999

    GMC Member

  • New Member
  • 3 posts

Posted 18 December 2009 - 09:16 PM

is there any way to remove the time system and transfer it to a START button so you have plenty of time to buy/upgrade weapons and start the round whenever you want?
just wondering. :)

Edited by Sonicdog999, 18 December 2009 - 09:18 PM.

  • 0

#56 1Sunkist64

1Sunkist64

    GMC Member

  • New Member
  • 24 posts

Posted 29 December 2009 - 07:38 PM

How do you make the tower rotate at what it is aiming at because I have cannons. :whistle:

Edited by 1Sunkist64, 29 December 2009 - 11:12 PM.

  • 0

#57 Ocliptis

Ocliptis

    GMC Member

  • New Member
  • 55 posts

Posted 29 March 2010 - 04:29 AM

Your tutorial is VERY COOL!
This is really good, and I will give you credit for the game, but i need some help.

How do you make enemy waves different,
for example 12 bombs come on wave 1 and wave 2 30 bombs and 15 blue bombs come and on wave 100, about 1000 rainbow bombs, 500 yellow bombs, and so on.
How do you have multi-enemy waves?

How do you make flame tower fire like using the particle function. It shoots out fire rapidly.
How do you make a ice blower tower. I make a single ice particle sprite and make it into a blower which blows lots of ice particles. It is still but targets bombs.

How do you make a tower rotate in the enemies direction?
How do you make a tower shoot; not one enemy but lots. When i put different types like red, blue, yellow, rainbow, white bombs, they only get the red bomb?? I want them to target every single type.

How do you make spikes. You can only place them on the path and they do not fire. They stay there and destroys upto 10 bombs and then it's gone.
A different upgrade system; like instead of upgrading to lvl 1 and all that, you could upgrade to example: "FROST TOWER" upgrade to PERMA FROST or FAST FIRING or FROST BOMBS?
Instead of a wave counter, could you have no, just a start round button? When a whole wave is finished, the start round button appears.
When your mouse hovers a button like THE FROST TOWER, a description appears like FROST TOWER, includes power and rate of fire.
A booster. If you place them near towers, they increase the surronding towers (in it's radius) power.
Bombs multiplying. If a black bomb is destroyed, if a blue bomb is destroyed, a black bomb appears just like in bloons tower defense how a blue bloon pops into a red bloon.
Screen clear function: If you click on like blackhole, a blackhole will appear in the center of the screen and suck up lots of bombs for 10 seconds.
Or if you activate "Atom BOMB" it clears the whole screen.

Grenade thrower. If bombs come, it starts spinning really fast shooting out 1 grenade every 2 millisecond at the enemy. But the grenades are very weak.

Immunities, like if you place an ICE BLOWER, it doesn't effect an ice bomb or if you place a FLAME TOWER it doesn't effect Fire bombs.

4 direction shooters. If you place one of these, it will shoot in all 4 directions at the enemy. good in corners.

How do you do all that? I tried, it didn't work.

I have been studying this tutorial for about 3 months while making my game 'Paper Mario Tower Defence' and probably know almost as much as the creator about this tutorial so I'll help on the things that I know about.

'How do you make enemy waves different,
for example 12 bombs come on wave 1 and wave 2 30 bombs and 15 blue bombs come and on wave 100, about 1000 rainbow bombs, 500 yellow bombs, and so on.'
You have to use something like this(this is what you replace in the tutorial script starting at //Creates enemies if needed for every array):

//Creates enemies if needed for every array
if wave_time < 600 wave_time += 1; //the 600 is the amount of seconds in the wave before the next wave comes.
if wave_enemies > 0 //this asks if there are any enemies left.
{
if(wave_time = (ee-wave_enemies)*15+15) //I recently found out that the 15's are the spaces between the enemies when they are created.
{
switch(floor(wave/1)) //this will switch the enemy every wave. Change the 1 to another number to have it switch for more waves. ex:if set to 2 then ob_enemy1 will be the enemy fought for 2 waves. Once you run out of 'cases' no more enemies will come.
{
case 1:instance_create(-32,0,ob_enemy1); break;
case 2:instance_create(-32,0,ob_enemy2); break;
case 3:instance_create(-32,0,ob_enemy3); break;

'How do you have multi-enemy waves?'
Again start replacing at the creates enemy for every array:

//Create enemies if needed for every array
if wave_time < 600 wave_time += 1;
if wave_enemies > 0
{
if wave_time = (ee-wave_enemies)*15+15
{
instance_create(-32,0,choose(ob_enemy1,ob_enemy2,ob_enemy3));//this will make a random enemy from the 3 enemies there. You can have up to 16 enemies.
wave_enemies -= 1;
}
}

Can't help you with the particle questions unfortunately.
I can't remember how make the tower rotate in the enemy's direction will try to figure that out because I want to know how to too.

'How do you make a tower shoot; not one enemy but lots. When i put different types like red, blue, yellow, rainbow, white bombs, they only get the red bomb?? I want them to target every single type.'
Have an 'ob_parent_enemy' and make it the parent of all enemies. Go into all of your towers and change the codes that say 'ob_enemy' to ob_parent_enemy.'

'How do you make spikes. You can only place them on the path and they do not fire. They stay there and destroys upto 10 bombs and then it's gone.'
This would be complicated becuase it would be a mix between tower and bullet and I haven't tried it so I can't help there. I couldn't help with the different upgrade idea yet either but I might get back to you if I figure it out in my next td game becuase I'm having that in it.

'Instead of a wave counter, could you have no, just a start round button? When a whole wave is finished, the start round button appears.'
Get rid of everything that mentions 'wave_time.'

'When your mouse hovers a button like THE FROST TOWER, a description appears like FROST TOWER, includes power and rate of fire.'
This is also very complicated and I couldn't tell you how. The booster idea is interesting, I'll try it and get back to you.

'Bombs multiplying. If a black bomb is destroyed, if a blue bomb is destroyed, a black bomb appears just like in bloons tower defense how a blue bloon pops into a red bloon.'
I noticed that many of your ideas are from bloons. You confused me so I'll use bloons as the example. Make it so that in the blue bloon's destroy event it changes into a red bloon(or two or three etc.).

'Screen clear function: If you click on like blackhole, a blackhole will appear in the center of the screen and suck up lots of bombs for 10 seconds.
Or if you activate "Atom BOMB" it clears the whole screen.'

Create a sprite that gets bigger in an animation. If you are using gm8 then seperate the collision masks. Then make it an object with these events.
CREATE
(not code)set alarm 0 to 300

ALARM 0
(not code)destroy instance, applied to 'self'

COLLISION WITH ENEMY/ENEMY PARENT
(not code)destroy instance, applied to 'other'

END OF ANIMATION
(code)
image_speed=0

'Grenade thrower. If bombs come, it starts spinning really fast shooting out 1 grenade every 2 millisecond at the enemy. But the grenades are very weak.'
duplicate a bullet tower(any one that fires a bullet not a laser) then go into the create event and set 'rate' to 0.2 and 'damage' to 1.

Can't help with immunities and will get back to you for the four direction shooter.

Wow you have alot of questions, It took me an hour to write this reply. :D :)
If you have anymore questions then ask, though if you pm me I'll reply to you then put it on the thread.
  • 0

#58 EchoJerichoX

EchoJerichoX

    www.MetroidCoven.com

  • GMC Member
  • 506 posts
  • Version:GM8.1

Posted 29 March 2010 - 06:48 AM

Damn, awesome tutorial man!
  • 0

#59 Jarquafelmu

Jarquafelmu

    GMC Member

  • New Member
  • 4 posts

Posted 19 April 2010 - 02:36 AM

I was having trouble on the selling button of this tutorial. I've tried to follow your instructions exactly and yet when I use my sell button it sells the selected tower, but then tries to place a laser tower. I am not sure what is going wrong. I was hoping you could help me figure out what is going on here.

What should I include to help you know where my problem is? Also in my step event. The program doesn't find ii.price anywhere, calls it an unexpected variable.
  • 0

#60 Nubcake

Nubcake

    Nubcake

  • GMC Member
  • 1320 posts
  • Version:Unknown

Posted 20 April 2010 - 03:36 PM

6/5! very good!
  • 0




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users