This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-11-29 13:03:27

nickpapadaki
Scratcher
Registered: 2010-10-29
Posts: 22

How can I make A tower defence game?

Can you please give an example of such games in scratch?
Or at least give me a clue to how I can make them?  tongue


Curiosity killed the cat, but for a while I was a suspect.
Steven Wright

Offline

 

#2 2010-12-01 20:00:29

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: How can I make A tower defence game?

If you want to write a tower defense game where the little bad guys always walk toward the goal following the shortest path, read this:

http://www.policyalmanac.org/games/aStarTutorial.htm

It is just about the simplest tutorial on the A* algorithm I could find.

Last edited by BoltBait (2010-12-01 20:00:49)


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#3 2010-12-01 20:37:22

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: How can I make A tower defence game?

I've got one, it doesn't work online though.  Just do a search for tower defence.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#4 2011-01-02 20:17:40

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: How can I make A tower defence game?

Here is an example http://scratch.mit.edu/projects/08jackt/1502037

Last edited by MoreGamesNow (2011-01-02 20:17:52)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#5 2011-01-14 15:44:10

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How can I make A tower defence game?

I made a succesful tower defence game and you can download it to make one. The Teddy bears(your enemy) will have to follow a path that you program into them. I think thathis is just what you need. One last thing, the name of the project is Teddy bear tower defence.  I don't know why, but you can't search it up on Search, so you have to go to my Scratch account and lokk for it among my projects.


http://i46.tinypic.com/35ismmc.png

Offline

 

#6 2011-01-22 18:47:18

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How can I make A tower defence game?

If you want to make a tower defence game, to be able to buy towers, you have to have the following script on your buy turrent butten:
<when[ Buy basic turrent ]clicked>
<if> << <( {money}> 99  )> <and> <(  { Basic towers }< 4  )> >
<go back( 1 )layers>
<change{ Basic turrents }by(1)
<change{ money }by(-100)
<broadcast[ Placing #]
  And for your turrent:
#1
<when green flag clicked>
<hide>
<set size to( 30 )%>
#2
<when I receive[ Placing #]
<if><(  { Basic turrents }= 1 )>
<go to front>
<show>
<repeat until> <<  <not>  <touching[ Basic tower 2(or you could do the tower's color)}>>
<if><<  <not> <touching[Basic tower 2(or tower's color)]>
<set[ brightness ]effect to( 0%)
<else>
<set[ brightness ]effect to( -40%)]
<point in direction( 0 )
<forever>
<if><(  { Basic turrents }> 0 )>
<if><( <distance to[ Enemy 1] < 50  )>
<go to front>
<switch to costume[ 2 }
<point towards( Enemy 1)
<change{ Enemy health 1 }by( 10 )
<wait( 1 )second>
<point towards( Enemy 1)
<switch to costume[ 1 ]
<wait( 1 )secsc>
I hope that this helps!
Also, if you want to look at the other scripts in a tower defence game, download Teddy bear tower defence or Teddy bear tower defence #2. The only way you will be able to find it is by searching for ErnieParke and clicking on ErnieParke's stuff.


http://i46.tinypic.com/35ismmc.png

Offline

 

#7 2011-03-24 14:07:46

sebby384
New Scratcher
Registered: 2010-10-05
Posts: 10

Re: How can I make A tower defence game?

How do you get it so that the towers snap into place for example, on ' the biggest tower defense game on scrtch' . How does it work?

Offline

 

#8 2011-04-09 15:48:25

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How can I make A tower defence game?

Sorry about the messed up script.


http://i46.tinypic.com/35ismmc.png

Offline

 

#9 2011-05-08 23:05:08

BattleonGames
New Scratcher
Registered: 2011-04-01
Posts: 1

Re: How can I make A tower defence game?

For Clicking on the tower:
<when[ Buy Tower ]clicked>

Offline

 

#10 2011-05-09 07:19:01

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: How can I make A tower defence game?

sebby384 wrote:

How do you get it so that the towers snap into place for example, on ' the biggest tower defense game on scrtch' . How does it work?

<when[ Tower ]clicked>
<repeat until><<  <not> <mouse down?> >>
<go to[ Mouse Pointer ]>
<end>
<set{ X }to( <round( (( <x position> </> <{ width/height of invisible grid }> )) )>
<set{ Y }to( <round( (( <y position> </> <{ width/height of invisible grid }> )) )>
<go to x sad  (( <{ X }> <*> <{ width/height of invisible grid }> )) )y sad  (( <{ X }> <*> <{ width/height of invisible grid }> ))

You may have to adjust this with some addition and subtraction


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#11 2011-07-22 00:47:29

BritRRB
Scratcher
Registered: 2010-09-03
Posts: 7

Re: How can I make A tower defence game?

http://scratch.mit.edu/forums/viewtopic.php?id=51354#req_message

Offline

 

Board footer