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

#1 2012-01-14 15:07:59

Craigster001
New Scratcher
Registered: 2011-07-15
Posts: 5

Die when HP Reaches ZERO

So heres the game.
http://scratch.mid.edu/projects/Craigster001/2272454

My foe will not die when HP reaches zero.

Wait until<HP> =0
Change ghost affect by 100 (Should i switch with the hide block?)
Broadcast 'Die'
Stop script

However, the die does not work, nor does the foe merely dissapear.

Offline

 

#2 2012-01-14 15:12:14

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: Die when HP Reaches ZERO

Try wait until HP < 1 instead of = 0, to counter the possibility that it could skip past 0 and enter the negatives.

Last edited by Kileymeister (2012-01-14 15:12:45)


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#3 2012-01-14 15:22:32

fuz50
Scratcher
Registered: 2008-09-19
Posts: 100+

Re: Die when HP Reaches ZERO

I found your issue, it's just because your health dips below zero, so the script doesn't start.

Try adding this block (I linked the picture, since the pictures are off on the forums):
https://lh5.googleusercontent.com/-wv8p … 6/jbkb.gif

Hope this helps!  wink


http://img10.imageshack.us/img10/7404/cooltext529102298.jpg
http://siggen.toontown-click.de/sig1.pnghttp://siggen.toontown-click.de/sig2.png

Offline

 

#4 2012-01-14 15:30:40

plb36
Scratcher
Registered: 2011-10-16
Posts: 100+

Re: Die when HP Reaches ZERO

They are both right, fix that and you should be good to go.  smile


http://i1094.photobucket.com/albums/i456/plb36/myforumssig.png

Offline

 

#5 2012-01-14 17:12:24

K-Jam
Scratcher
Registered: 2010-04-17
Posts: 100+

Re: Die when HP Reaches ZERO

<when green flag clicked>
<forever>
<if><( health <=> 0 )>
<broadcast[ die


http://images.inmagine.com/img/imagezoo/iz162/Iz162012.jpg COMPASS!!!

Offline

 

#6 2012-01-15 04:46:43

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Die when HP Reaches ZERO

Put:

When green flag clicked
Wait until "Health"=(0)  or  "Health"<(0)
Broadcast "Game over"

That should work.

Last edited by RedRocker227 (2012-01-16 10:37:51)


Why

Offline

 

#7 2012-01-15 19:18:15

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: Die when HP Reaches ZERO

or another way is to set the HP to 0 if it becomes negative because negative hp doesn't look too good. but the above ways should work too.

Offline

 

Board footer