Discuss Scratch

samwinters
New Scratcher
7 posts

restarting lives

Hi! I'm making my first game, so i probably will have a lot of questions. How do i restart the lives once they get to zero? Please explain step by step. Thanks!
speckosaurus
Scratcher
100+ posts

restarting lives

It's helpful to have one section of code that will initialise certain variables whenever you need to. For example, when you start a game or restart it, you'll want to reset score to 0, lives to 3 (or whatever number you decide), clear any inventory your game might have, stuff like that! If you put it in one section that you can call any time, it saves you from having to repeat that code.

If you haven't used “broadcast” before, this sends a message which can be received anywhere else in your game to do something. In this case, when you start the game or when your character dies, you will use
broadcast [start v]

The two main places you will probably use this are
when green flag clicked
broadcast [start v]
and
when green flag clicked
forever
if <[lives v] = [0]> then
broadcast [start v]
end
end

Anywhere else in your scripts, you will have something like the following:
when I receive [start v]
set [score v] to [0]
set [lives v] to [3]
Followed by whatever other code you need to make your game run. Play around with it and see what you can do. There are multiply ways to do things in Scratch, but I think this is one of the simplest.

Last edited by speckosaurus (Aug. 18, 2015 21:59:34)

samwinters
New Scratcher
7 posts

restarting lives

Im trying to make it broadcast start but nothing shows up. What happens now?

Last edited by samwinters (Aug. 18, 2015 22:23:52)

Powered by DjangoBB