Discuss Scratch

SeaBoundRhino
Scratcher
62 posts

Scratch Explosion?

So, I am making this game. After you beat the first part of the second level, the win zone is switched to a different place. But when this happens, the enemy stops moving and the square sprite doesn't die by the black walls like it is suppose to. I need your help to figure what is wrong.

The game: Cublox's Mighty Adventure
DanloVorje
Scratcher
100+ posts

Scratch Explosion?

Okay, I think I've figured out what's going on.

if <<<touching color [#0f0]?> and <(level) = [2]>> and <(level 2 unlocked) = [0]>> then
et cetera
end

^When this statement is true, it sets (level 2 unlocked) to 1 and tells the background to change… but the script then immediately checks

if <<<touching color [#0f0]?> and <(level) = [2]>> and <(level 2 unlocked) = [1]>> then
et cetera
end

The problem is that the background takes some time to change, and this if statement detects that the Square is still touching green and that (level 2 unlocked) is indeed equal to 1 (since the script just set it to that). Thus it sets (level) to three, and you haven't made scripts that tell the sprites what to do on level three–the Square doesn't detect the walls, and the enemy doesn't move.

Simplest way to fix this is to put one of these:
wait (.1) secs

after
broadcast [level 2 unlocked v]
set [level 2 unlocked v] to [0]
go to x: (-210) y: (-50)

to give the background enough time to change before the script proceeds.

…I hope that explanation was clear enough. If you have more questions, just ask!

–Danlo
SeaBoundRhino
Scratcher
62 posts

Scratch Explosion?

DanloVorje wrote:

Okay, I think I've figured out what's going on.

if <<<touching color [#0f0]?> and <(level) = [2]>> and <(level 2 unlocked) = [0]>> then
et cetera
end

^When this statement is true, it sets (level 2 unlocked) to 1 and tells the background to change… but the script then immediately checks

if <<<touching color [#0f0]?> and <(level) = [2]>> and <(level 2 unlocked) = [1]>> then
et cetera
end

The problem is that the background takes some time to change, and this if statement detects that the Square is still touching green and that (level 2 unlocked) is indeed equal to 1 (since the script just set it to that). Thus it sets (level) to three, and you haven't made scripts that tell the sprites what to do on level three–the Square doesn't detect the walls, and the enemy doesn't move.

Simplest way to fix this is to put one of these:
wait (.1) secs

after
broadcast [level 2 unlocked v]
set [level 2 unlocked v] to [0]
go to x: (-210) y: (-50)

to give the background enough time to change before the script proceeds.

…I hope that explanation was clear enough. If you have more questions, just ask!

–Danlo
Wow! Thanks for the help! It's working now! You are incredibly good at explaining things, by the way.

Powered by DjangoBB