Student Game Help--Projectiles

Link to the project or level: Game Lab - Code.org

What I expect to happen: When 1 key is pressed, projectiles should fire

What actually happens: projectiles not firing

What I’ve tried: I haven’t tried much–this code seems extra complex (usually, this student does complex work)—I am also not an expert by any means, so I am not clear on what exactly is wrong

Greetings, @Flynn_Lives
Please refer to my old post that I have sent already: Student Game Collider Help - #2 by pluto

Hi @Flynn_Lives,

Great graphics! There was a good deal happening that I could see as to why the projectiles aren’t seen.

The original error for “isTouching not defined” is because all the variables and sprites are created inside an if statement which means that are not accessible outside that if statement. The isTouching conditional can’t see the other sprites/variables to test if they are touching. So, I moved all those up to the top outside of the draw loop so the whole program can access them.

The Bullets25mmGauGatling sprite was quite small with LOTS of canvas so I cropped it and scaled it to be larger to see it more easily for debugging.

The dir variable for rotation of the bullet will still need to be debugged but it looks like the student had a good start so I’ll let them continue to work on it now that the projectile can be seen.

Also, remember that if the sprites are created first at the top of the code, they are the farthest back in the layers so make sure the Bullets25mmGauGatling is one of the last sprites declared so it can be seen and not hidden behind other sprites.

This remix shows my basic adjustments. The projectile is now showing and we’d love to see the game once it is build out with aiming and rotation of the projectile:)