Shooter game debug

I’m a newbie CS teacher here just learning javascript myself, so can anyone help with this issue.
Student is making a “shooter game.” Wants the “explosion” sprite show up when the arrow touches the gem but the explosion appears over and over rather than just showing once. Any ideas? Here is the remixed project so far:

Thank you in advance!

1 Like

I’m not 100% on this, but maybe you need to create the burst variable outside of the loop and just call it in the loop instead.

1 Like

I think @edavis comment is a good one. Creating sprites inside the draw loop can be problematic because each time you go through the draw loop, it creates the sprite over and over again. You can create it first and make it invisible and then make it visible inside the draw loop at the appropriate time and avoid some of those issues.

Another thing to look at is how long the sprite is in collision with the target. They may be triggering the collision more than once. Making the explosion a little smaller (or faster), may help to control that.

If your student is able to make some of those adjustments and it doesn’t fix the issue, check back in with us and we’re happy to look at it again.


1 Like

Thank you for the idea!