Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Lives
- aiyuen1
-
3 posts
Lives
Im trying to make this thing where when I have 5 coins it gives me a life. How do I make it so that when I die, I get to still live.
- fakemaker1337
-
99 posts
Lives
do: When die, if coins>4 then change coins by -5
if <(die )= [1]> thenIs this what you mean?
if <(coins) > [4]> then
change [coins] by (-5)
end
end
Last edited by fakemaker1337 (Feb. 25, 2022 15:06:42)
when green flag clicked
forever
if <<On Scratch> and <On Forums>> then
repeat until <(help need near me) = [no]>
if <(help need near me) = [yes]> then
Help!
end
end
end
end
- aiyuen1
-
3 posts
Lives
I meant like and extra life not the coins. So If i run intro a wall (Im doing a 2d maze game) then I still get to live and not restart
- helloworldbyeworld
-
1000+ posts
Lives
Okay, then try this: I meant like and extra life not the coins. So If i run intro a wall (Im doing a 2d maze game) then I still get to live and not restart
when green flag clicked
set [Lives v] to (1) // or how many lives you get at the start of the game
forever
if <touching [wall v] ?> then // or whatever condition makes you die
change [Lives v] by (-1)
wait until <not <touching [wall v] ?>> // or <not <whatever condition makes you die>>
end
if <(Lives) < (1)> then
die::grey
stop [all v]
end
end
To have the player gain an extra life, such as when completing a level, change the lives variable by 1.
Helloworldbyeworld | 1200+ posts
Have a great day
- Discussion Forums
- » Help with Scripts
-
» Lives