Space Shooter - Code Check / Help

Hi,
I have made an Asteroid Game (Space Shooter) and have everything working pretty well. I have used a few projects from the gallery to help get the code (CoBlocks) I need. I am however a bit new to coding in general.

The problem I have is that sometimes the game ends before all of the asteroids are shot and destroyed. I’m not sure what is causing this and would really appreciate any help with fixing the problem.

Images of the code have been attached and the project link is below. Please let me know if there is anything else I can add to this post that would help with debugging.

Thank you.

**



** https://edu.delightex.com/FEX-VDJ

From the code you’ve shared, the most likely cause of the game ending too early is that your “game over” or “win” condition is triggered based on a variable or collision check that doesn’t accurately track the number of remaining asteroids.
Add a Variable to Track Remaining Asteroids
Create a new variable called:
asteroidsRemaining
set variable asteroidsRemaining to 9

  • Every time an asteroid is destroyed, decrease this variable by 1.
  • Only end the game when asteroidsRemaining = 0.
2 Likes

Thank you very much for your suggestion and help. Between you and a little help from ChatGPT, I now have a fully functioning shooter game.

For anyone interested, this is the game link:

1 Like