Can you please give an example of such games in scratch?
Or at least give me a clue to how I can make them?
Offline
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)
Offline
I've got one, it doesn't work online though. Just do a search for tower defence.
Offline
Here is an example http://scratch.mit.edu/projects/08jackt/1502037
Last edited by MoreGamesNow (2011-01-02 20:17:52)
Offline
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.
Offline
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.
Offline
For Clicking on the tower:
<when[ Buy Tower ]clicked>
Offline
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 (( <{ X }> <*> <{ width/height of invisible grid }> )) )y (( <{ X }> <*> <{ width/height of invisible grid }> ))
You may have to adjust this with some addition and subtraction
Offline