This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-02-20 21:02:02

nickyg17
New Scratcher
Registered: 2013-02-20
Posts: 3

How to end game when variable reaches zero?

I'm going to make a game with 5 lives but I have a problem. Iv'e been trying everything but I don't know how to make a game and if a variable goes to zero.I'm trying to use if then find something that fits into the spiked then somehow make it if life +0 the game ends. Please tell me how to do this. Please

Offline

 

#2 2013-02-20 21:11:48

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: How to end game when variable reaches zero?

No problem.  smile

I am assuming you are saying that you want to make a script that makes the game end if the lives variable gets lower than 1:

When gf clicked
set [lives v] to (5)

When gf clicked
If <[lives] < [1]>
broadcast [game over v]
When I receive [game over v]
Whatever you want it to do once game over...
Remember, you need to subtract 1 from "lives" each time the player does something to lose a life. Do this:

change [lives v] by (-1)
Hope that helps. If you have any more questions, please ask away.  smile

Regards,

CAA14

Last edited by CAA14 (2013-02-20 22:34:11)

Offline

 

#3 2013-02-21 20:21:18

nickyg17
New Scratcher
Registered: 2013-02-20
Posts: 3

Re: How to end game when variable reaches zero?

say[Didn't work! Sorry!]

Offline

 

#4 2013-02-21 20:23:16

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: How to end game when variable reaches zero?

nickyg17 wrote:

say[Didn't work! Sorry!]

Can you post your scripts?

Regards,

CAA14

Offline

 

#5 2013-02-21 20:25:51

piguillaud
Scratcher
Registered: 2010-06-19
Posts: 100+

Re: How to end game when variable reaches zero?

when gf clicked
forever
if <<variable> = [0]>
stop all
end

Offline

 

#6 2013-02-22 09:30:12

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How to end game when variable reaches zero?

piguillaud wrote:

when gf clicked
forever
if <(Lives) = [0]>
stop all
end

Fixed; variables are supposed to have parenthesis around them, not <>. Also, I changed the variable's name to better fit the situation.


http://i46.tinypic.com/35ismmc.png

Offline

 

#7 2013-03-05 17:17:31

nickyg17
New Scratcher
Registered: 2013-02-20
Posts: 3

Re: How to end game when variable reaches zero?

ErnieParke wrote:

piguillaud wrote:

when gf clicked
forever
if <(Lives) = [0]>
stop all
end

Fixed; variables are supposed to have parenthesis around them, not <>. Also, I changed the variable's name to better fit the situation.

thnx dude your right

Offline

 

Board footer