Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » New Scratcher Trying To Learn
- Jiangxi123
- New to Scratch
1 post
New Scratcher Trying To Learn
Hi, I'm trying to make a catching game. How do I reset the score is a sprite misses the other?
Also, How do I add a screen with the score and a restart button?
Also, How do I add a screen with the score and a restart button?
- imfh
- Scratcher
1000+ posts
New Scratcher Trying To Learn
I'm assuming you are using this tutorial. If you aren't, you might want to check it out.
When the sprite hits the bottom and goes back to the top, you can use ‘set score 0’ to reset the score. Alternatively, you can make the game end. To do this, you will want to use a broadcast so the button knows to appear.
What you'll end up with could look something like this:
When the sprite hits the bottom and goes back to the top, you can use ‘set score 0’ to reset the score. Alternatively, you can make the game end. To do this, you will want to use a broadcast so the button knows to appear.
What you'll end up with could look something like this:
when green flag clicked
broadcast [Start Game v] // Tell everything to start
when this sprite clicked // In the button
broadcast [Start Game v] // Tell everything to start
when I receive [Start Game v] // In the button
hide // We don't want it to get in the way during the game
when I receive [End Game v] // In the button
show // We need to see it to click it
when I receive [Start Game v] // In the ball / sprite being caught
forever
if <touching [Catching v] ?> then
change [Score v] by (1)
go to [random-position v]
else
if <(y position) < [-150]> then
broadcast [End Game v] and wait // Tell the button to appear
stop [All v] // Stop the game
end
end
Scratch to Pygame converter: https://scratch.mit.edu/discuss/topic/600562/
- Discussion Forums
- » Help with Scripts
- » New Scratcher Trying To Learn