Level up Galaga type game with score

Hi there, I`m making a StarWars galaga type of game, but couldnt make it to change level with the score.
It does change level, just jumps from the first to the 3d ???

thanks for your support

https://makecode.com/_HrwHqVdFHf5b here is my code… it jumps on level, ignoring one, and the ships doesnt change their image (just one, but rest doesnt).

1 Like

Oh, this is awesome! I love the sprites and overall feel of the game! A couple things are causing this behavior:

  1. Level jumping: the code to change the current level here:

is actually running every frame once you hit 11 points. So you go from level 1 to 2, but the next frame you immediately increment it to level 3. It’s actually going beyond 3, but there’s no code to set backgrounds for that so it appears stuck on three.

To fix this, you really only need to change the CurrentLevel and call setLevel once the score has hit a specific number. One way to do this is by moving the if statement next to where you are changing the score, like so:

  1. Enemy image: the problem with the enemy image is a little more involved! First, since the CurrentLevel was being incremented every frame, “CurrentLevel = 3” would only be true for one frame, so it only set the image of one ship. Additionally, when you set the image of Enemy1 here:


it only sets the image of the most recently created enemy. This will work because you are not creating enemies very frequently, but if you created more than one at a time, it would only set one of the images. Another way to do this would be to have an “enemyImage” variable that holds the image. You could change this variable when you change the background as well:

I hope that helps! And here’s the full game with the changes described above:


I Apreciate your help so much. Here is another example that was working out a little bit better than my last https://makecode.com/_cbEiEpRjC7EH


Oh awesome, I love the different types of enemies :smiley: Definitely let us know if you run into any other issues, the game is looking fantastic so far!

1 Like