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

#1 2012-10-22 21:27:27

embles
New Scratcher
Registered: 2012-10-22
Posts: 2

Lives

Hi there, I'm trying to make lives on a game project.
It's a charizard flying avoiding two 'bubbles', I'm trying to get him to lose a life everytime he touches one.
I've tried numerous ways of getting it to work,
[scratchblocks]
when gf clicked
say 'avoid the bubbles!' for 5 secs
set Lives to 3
If touching bubble1
   set lives to lives = -1
If touching bubble2
   set lives to lives = -1
If lives = 0
   think 'Game Over'

I've also tried making the bubbles the same colour and using if touching the colour, I have tried to make it lose lives if the bubbles touch charizard.
Thought it might be a problem with the sprites so stopped them changing costume and changed them entirely to no avail.

Offline

 

#2 2012-10-22 21:37:40

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

Re: Lives

embles wrote:

Hi there, I'm trying to make lives on a game project.
It's a charizard flying avoiding two 'bubbles', I'm trying to get him to lose a life everytime he touches one.
I've tried numerous ways of getting it to work,

when gf clicked
say [avoid the bubbles!] for (5) secs
set [Lives v] to (3)
forever
If (touching [bubble1 v]?)
   change [lives v] by (-1)
   wait until <not (touching [bubble1 v]?)>
end
If (touching [bubble2 v]?)
   change [lives v] by (-1)
   wait until <not (touching [bubble2 v]?)>
end
If <(lives) = (0)>
   think [Game Over]
end
I've also tried making the bubbles the same colour and using if touching the colour, I have tried to make it lose lives if the bubbles touch charizard.
Thought it might be a problem with the sprites so stopped them changing costume and changed them entirely to no avail.

The problem is that you had set lives to -1 and not changed it by -1 whenever you touched a bubble. Also, you forgot to add a wait block to make sure that you didn't instantly lose the game by touch a bubble once. Anyway, I edited your scripts above to make them work.

Anyhow, I hope that this helps!

Last edited by ErnieParke (2012-10-22 21:44:11)


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

Offline

 

#3 2012-10-22 21:41:09

embles
New Scratcher
Registered: 2012-10-22
Posts: 2

Re: Lives

Ah that's great thanks, works perfect now.  smile

Offline

 

#4 2012-10-22 21:45:17

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

Re: Lives

embles wrote:

Ah that's great thanks, works perfect now.  smile

Well that's good. And your welcome!

Last edited by ErnieParke (2012-10-23 06:38:08)


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

Offline

 

#5 2012-10-23 22:57:37

SOScratch
Scratcher
Registered: 2010-02-01
Posts: 100+

Re: Lives

Tip: You must change a variable and not set it.
Or else it will just go to that amount without doing much else.

But it seems it works now.

Good to see.


-SOScratch
Scratch On!

Offline

 

Board footer