Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Sprite coding not working - when lives get to 0, character doesn't die. Please help!
- code-man2009
-
Scratcher
3 posts
Sprite coding not working - when lives get to 0, character doesn't die. Please help!
Hi there - I'm writing this with my 10-year old son, who created the game. He created some scripting for his sprite where when the character's lives are <1, a game over/stop script should be activated. But it doesn't seem to be working, and he's not sure what he did wrong. Is there a way for someone to look at his code and tell us what he needs to change? Here is the link to the project: https://scratch.mit.edu/projects/328233537/
If needed, I'm happy to set up a Zoom call and share our screen.
If needed, I'm happy to set up a Zoom call and share our screen.
- LordThror
-
Scratcher
100+ posts
Sprite coding not working - when lives get to 0, character doesn't die. Please help!
You need to put a forever loop around it like this:
Otherwise, you will only die if Your Lives = 0 exactly when the green flag is clicked.
when green flag clicked
forever
if <[your lives] < [1]> then
broadcast [stop v]
end
end
Otherwise, you will only die if Your Lives = 0 exactly when the green flag is clicked.
- gor-dee
-
Scratcher
1000+ posts
Sprite coding not working - when lives get to 0, character doesn't die. Please help!
Or better still
when green flag clicked
wait until <[lives] < [1]>
broadcast [stop v]
- deck26
-
Scratcher
1000+ posts
Sprite coding not working - when lives get to 0, character doesn't die. Please help!
Or better stillAnd even betterwhen green flag clicked
wait until <(lives) < [1]>
broadcast [stop v]
when green flag clickedas otherwise if you run a project after hitting 0 lives Scratch will remember the value when you restart without reloading. You may have another green flag script that resets the value but will it run before this one?
set [lives v] to [3]
wait until <(lives) < [1]>
broadcast [stop v]
- AlphaDragonAK16
-
Scratcher
22 posts
Sprite coding not working - when lives get to 0, character doesn't die. Please help!
I did notice that your wizard moves slower when he's moving to the left than to the right. Might want to check that out.
- code-man2009
-
Scratcher
3 posts
Sprite coding not working - when lives get to 0, character doesn't die. Please help!
ya i know I will fix dat
- Discussion Forums
- » Help with Scripts
-
» Sprite coding not working - when lives get to 0, character doesn't die. Please help!