Discuss Scratch

mac2009
Scratcher
16 posts

Projectile not firing, main character moving while level is rendering, main character not following instructions [CLOSED]

Here's some background: each level begins with the “Sequence” sprite broadcasting RENDERB. The “Background” sprite receives this, and creates the background accordingly. It broadcasts RENDERW, which is received by the “Walls” sprite, which goes on to create the walls. It then broadcasts RENDERDONE, causing all the sprites necessary for the level (primarily MC, Hitbox, Projectile, and Sequence) to do their tasks. Once the Hitbox reaches the Sequence (door to get to the next level), RENDERB is broadcast again, and so on. RENDERB also instructs the MC, Hitbox, Projectile, and Sequence sprites to hide, and they do not come back into play until, of course, RENDERDONE.

After the level is created, the main problem is that the projectile does not fire, and you can move the main character while the level is still rendering. Not to mention, the main character seems to ignore the commands to place it in the proper spawn location entirely. I think the root of this is that I don't understand the broadcast/receive system very well. You can see in the “Hitbox” sprite that the scripts determined by RENDERDONE still go on even after they touch Sequence. Also, code inside is a bit messy at spots.

Link: Rampage

Last edited by mac2009 (June 11, 2017 15:36:08)


Fame, fortune, glory, and pie.
drmcw
Scratcher
1000+ posts

Projectile not firing, main character moving while level is rendering, main character not following instructions [CLOSED]

The projectile doesn't fire because item 3 of Booleans is set so the loop to detect the key press and create the projectile isn't running.

Rather than chaining broadcasts like you do it's better to have a main control sequence e.g

broadcast [RenderB v] and wait
broadcast [RenderW v] and wait
broadcast [Render done v]
notice the “and wait” so that each broadcasts waits for all its scripts to complete before continuing. You get much better control and don't have to fudge things with wait blocks. At the moment for the walls, all the clones will receive the render broadcast, but you do delete them so just the sprite should run the main render script, as long as it maintains that wait at the beginning.

You should look up custom blocks and the run without refresh setting as you can then render your background instantly instead of waiting for it to be drawn like it is.

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
mac2009
Scratcher
16 posts

Projectile not firing, main character moving while level is rendering, main character not following instructions [CLOSED]

drmcw wrote:

The projectile doesn't fire because item 3 of Booleans is set so the loop to detect the key press and create the projectile isn't running.

Rather than chaining broadcasts like you do it's better to have a main control sequence e.g

broadcast [RenderB v] and wait
broadcast [RenderW v] and wait
broadcast [Render done v]
notice the “and wait” so that each broadcasts waits for all its scripts to complete before continuing. You get much better control and don't have to fudge things with wait blocks. At the moment for the walls, all the clones will receive the render broadcast, but you do delete them so just the sprite should run the main render script, as long as it maintains that wait at the beginning.

You should look up custom blocks and the run without refresh setting as you can then render your background instantly instead of waiting for it to be drawn like it is.
The project's working now, though it'll probably be screwed up again when I try to add in the enemies, heheh.

Thanks for the help!

Fame, fortune, glory, and pie.

Powered by DjangoBB