Discuss Scratch

Jedi_Edrich
Scratcher
11 posts

Health script that ends game when it reaches 0

I need a simple health script that ends the game when it reaches zero.
CodeLegend
Scratcher
500+ posts

Health script that ends game when it reaches 0

when green flag clicked
set [Health v] to [100]
wait until <(Health) < [1]>
stop [all v]
I hope that this helps!
wkelly42
Scratcher
100+ posts

Health script that ends game when it reaches 0

if <whatever happens that makes you lose health happens> then

change [ health] by (-1)

end
if <health = 0> then
stop [all]
end

Last edited by wkelly42 (Nov. 22, 2013 02:36:39)


My Retro Arcade:
COMPLETED: Frogger, Missile Command, Computer Space.
IN DEVELOPMENT: Barnstorming, Time Pilot, Defender, River Raid, Karateka
GameMakerDelux
Scratcher
1 post

Health script that ends game when it reaches 0

(whatever kills u)
mastercoder2800
Scratcher
6 posts

Health script that ends game when it reaches 0

when green flag clicked
forever

if <touching [ v] ?> then
broadcast [ v]

end

end

when I receive [ v]
next costume

when green flag clicked
forever

if <(costume #) = [ Whatever number the last one is]> then

stop [ v]
end

end
Kat--
Scratcher
24 posts

Health script that ends game when it reaches 0

I would've done

when green flag clicked
set [ character health ] to [ 100]
forever

if <(character health ) = [0 ]> then

broadcast [end game v]
stop [all v]
end

end

but all the others work. Use the one that you understand the most

——
mew mew mew
ice cream clicker! (still in beta)
Koopakid6000
Scratcher
100+ posts

Health script that ends game when it reaches 0

Kat-- wrote:

I would've done

when green flag clicked
set [ character health v] to [ 100]
forever

if <(character health ) = [0 ]> then

broadcast [end game v]
stop [all v]
end

end

but all the others work. Use the one that you understand the most
Most people use less than 1 rather than equals 0 because there are many cases where the enemy will deal enough damage to give the player negative health, so in that case equals 0 could allow continuation if they gave less than minimum health.

define Awesome 
Koopakid6000 ::operators

undefined //I lost my coding purpose so now I destroy kumquats.












letsPROGRAM
Scratcher
34 posts

Health script that ends game when it reaches 0

when green flag clicked
forever

if <(score) < [0 ]> then

stop [all]
end

end

Last edited by letsPROGRAM (June 6, 2016 19:55:07)


letsPROGRAM

LitzyA603
New to Scratch
2 posts

Health script that ends game when it reaches 0

when green flag clicked
set [health] to [100]
wait until <[Health] = [0]>
broadcast [Game Over]
stop [ all]


To broadcast a Game Over screen

Create a sprite to broadcast then add

when I receive

Last edited by LitzyA603 (May 25, 2023 17:05:20)

LitzyA603
New to Scratch
2 posts

Health script that ends game when it reaches 0

when I receive [Game over]
show


Hide it first

Last edited by LitzyA603 (May 25, 2023 17:06:30)

Powered by DjangoBB