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

#1 2008-02-18 04:29:09

Splattafax
Scratcher
Registered: 2008-02-08
Posts: 12

Health problems

there is probably a tutorial out there somewhere, but i cant find it, anyways, Ive been trying to make health using variables, and so far, its not going too good, I need to know how to make a sprite "die" when it's health variable reaches 0, can someone please tell me how?


Teachin' Fools Some Basic Rules!

Offline

 

#2 2008-02-18 04:48:16

ihaveamac
Scratcher
Registered: 2007-09-22
Posts: 1000+

Re: Health problems

The sprite who has the health:
<when green flag clicked>
<wait until> << <( <{ health }> <=> 0 )> <or> <( <{ health }> <<> 0 )> >>
<broadcast[ game over

The sprite that shows Game over sign:
<when I receive[ game over
<show>
<go to front>
<stop all>

If you need more help, ask me on my Messaging Center

Last edited by ihaveamac (2008-02-18 04:51:41)


~ihaveamac - visit ihaveamac.net

Offline

 

#3 2008-02-18 05:03:07

Splattafax
Scratcher
Registered: 2008-02-08
Posts: 12

Re: Health problems

Thank you so much, tha just made this project so much easier


Teachin' Fools Some Basic Rules!

Offline

 

#4 2008-02-18 05:54:57

ihaveamac
Scratcher
Registered: 2007-09-22
Posts: 1000+

Re: Health problems

To answer your question,

You wrote:

ok, the thing you told me, it didnt work, its probably because i did it wrong,ill tell you the whole story so far: I press the button, which makes the guy shoot, minusing the health of the enemy by 0 - 20, when the enemie's reaches 0, he is supposed to dissapear, (because he walks forever), and the exact same looking sprite, except with costumes of dying, is supposed to take his place then dissapear, then the first enemy (walking one) reappears and this keeps on happening, can you please help me with this?

Ok.  The enemy's script:
<when green flag clicked>
<forever>
<the enemy's actions here>
<if> << <( <{ health }> <=> 0 )> <or> <( <{ health }> <<> 0 )> >>
<hide>
<change{ score }by( 1  (if you are putting a score in it)
<wait( <pick random( 1 )to( 10 )secs>
<show>
<go to x sad  240 )y sad  <pick random( -180 )to( 180
<end>
<end>

Did this help?


~ihaveamac - visit ihaveamac.net

Offline

 

Board footer