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

#1 2013-04-19 07:16:52

Imaginos
New Scratcher
Registered: 2013-03-06
Posts: 56

Please HELP!!! Double death...

I've got a problem with my scripting on a game that I'm working on. In this game the player starts off with 5 lives and when they crash their space shuttle into the walls the shuttle explodes (this consists of a few costume changes for the shuttle sprite) and 1 life is lost... or at least that is the intention. The problem I have is that the explosion sequence happens twice & two lives are lost.

I'm no good with Scratchblocks but I will try to explain the bits of code involved:

To call up the death sequence I have used...

if touching colour (red)?
set "SX" to 0
set "Thrust" to 0
set "Gravity" to 0
broadcast "Die"
stop script

and "Die" broadcast looks like this...

when I receive "Die"
switch to costume "Shuttle2"
wait 0.2 secs
switch to costume "Shuttle3"
wait 0.2 secs
switch to costume "Shuttle4"
wait 0.2 secs
set ghost effect to 50
wait 0.2 secs
hide
switch to costume "Shuttle1"
wai 0.6 secs
change "Lives Left" by -1
if "Lives Left" >1
set "Level" to 1 (sets the player back to the first level)
broadcast "BG" (this is the broadcast that draws the level)
broadcast "Start" (sends you back to the main loop)
else
set "Lives Left" to 0 (not sure if I need this line)
broadcast "Fin" (broadcast the "Game Over" message)

Can anyone help?

Offline

 

#2 2013-04-19 07:23:07

Gravitation
New Scratcher
Registered: 2012-09-26
Posts: 500+

Re: Please HELP!!! Double death...

Change your

broadcast [Die v]
to
broadcast [Die v] and wait
If that doesn't help, it's probably because your shuttle is still touching red /after/ the death sequence. Also, check for 2 scripts that may be doing the same thing.  smile

Offline

 

#3 2013-04-19 08:12:17

Imaginos
New Scratcher
Registered: 2013-03-06
Posts: 56

Re: Please HELP!!! Double death...

Thanks Gravitation. Using...

broadcast "Die" and wait

...didn't make any difference but it gave me an idea of where the problem might lie.

I changed

broadcast "BG"

to

broadcast "BG" and wait

and that seems to have fixed it.
smile

Offline

 

Board footer