Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Health script that ends game when it reaches 0
- 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 clickedI hope that this helps!
set [Health v] to [100]
wait until <(Health) < [1]>
stop [all v]
- 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
- 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
but all the others work. Use the one that you understand the most
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)
mew mew mew
ice cream clicker! (still in beta)
- Koopakid6000
- Scratcher
100+ posts
Health script that ends game when it reaches 0
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. I would've donewhen 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
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)
- Discussion Forums
- » Help with Scripts
- » Health script that ends game when it reaches 0