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

#1 2012-02-22 20:22:36

DaScratcher101
Scratcher
Registered: 2012-02-16
Posts: 41

How do you make functionable lives?

Currently, i'm using variables to decide if, say, life one should be hidden and not life three. So, in my game if a cheese falls down and lands on the invisible sensor, the computer will be too fast and take out two lives instead of one. So, in other words, the variables will move up 2, not one. I tried a different way, but that way it totally bugged, and the cheese would be hidden, until it ate off all the variable lives. Then I decided to try making one life lost if the cheese fell, and since the variable goes up by 2, i would make each life get lost every even number in the variable until it reaches six. (2,4,6) Then all the lives would be lost, and it was a game over. But the cheese just got hidden, and ate off the numbers of the variable until it reached six. Any suggestions? This is the script I used.

forever
if [touching sprite 17 v]
broadcast [wah? v]
Change [lives v] by [1]
end
when I receive [wah? v]
do random things not including hiding and showing buttons

Offline

 

#2 2012-02-22 20:29:09

CheeseMunchy
Scratcher
Registered: 2008-10-13
Posts: 1000+

Re: How do you make functionable lives?

Well to salve your problem with lives going down by two just do this:

forever
if (touching [sprite 17])
wait until <not (touching [sprite 17])>
broadcast [wah? v]
Change [lives v] by [1]
end
A game about Cheese.... I like it.

Edit: fixed.

Last edited by CheeseMunchy (2012-02-22 20:38:01)


6418,

Offline

 

#3 2012-02-22 20:30:52

Stealth2800
Scratcher
Registered: 2010-05-03
Posts: 38

Re: How do you make functionable lives?

CheeseMunchy wrote:

Well to salve your problem with lives going down by two just do this:

forever
if (touching sprite 17)
broadcast [wah? v]
Change [lives v] by [1]
wait until [touching sprite 17 v]
end
A game about Cheese.... I like it.

Would this work? Doesn't seem like it would, and I'm too lazy to go and test it.

You could always just replace the normal broadcast block with the "broadcast ____ and wait" block.  Then move the "change lives by 1" script to the "when I receive wah?" script.

EDIT: @CheeseMunchy About your fix: That would cause the lives not to go down until the player isn't touching the hazard, which is not how lives are handled in a typical game.

This would work better:

forever
if (touching [sprite 17])
broadcast [wah? v]
Change [lives v] by [1]
wait until <not (touching [sprite 17])>
end

Last edited by Stealth2800 (2012-02-22 20:49:05)

Offline

 

#4 2012-02-22 22:47:31

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: How do you make functionable lives?

Instead of having the invisible "floor"/sprite detect if the cheese is touching it and removing lives, have the cheese detect it. So when the cheese touches the floor, it hides and gives one point, goes to a new position and then repeats the process.

Does that make sense?

Offline

 

#5 2012-02-23 10:33:47

DaScratcher101
Scratcher
Registered: 2012-02-16
Posts: 41

Re: How do you make functionable lives?

Magnie wrote:

Instead of having the invisible "floor"/sprite detect if the cheese is touching it and removing lives, have the cheese detect it. So when the cheese touches the floor, it hides and gives one point, goes to a new position and then repeats the process.

Does that make sense?

Woah, thanks! I understand. I can't believe i didn't think of that myself >.<

Offline

 

#6 2012-02-23 17:09:19

mitchboy
Scratcher
Registered: 2011-11-29
Posts: 59

Re: How do you make functionable lives?

CheeseMunchy wrote:

Well to salve your problem with lives going down by two just do this:

forever
if <touching [sprite 17 v]?>
wait until <not <touching [sprite 17 v]?>>
broadcast [wah? v]
Change [lives v] by [1]
end
A game about Cheese.... I like it.

Edit: fixed.

Fixed again. Anyway, what Magnie said. You could also make it so the cheese broadcasts it, then moves elsewhere so it doesn't keep repeating, if it works with the game.

Last edited by mitchboy (2012-02-23 17:10:04)


Quote of the week: "I am NOT being DRAMATIC!" ~Looney Tunes
Check out my newest game here!

Offline

 

Board footer