# Spaceshooter game BUGS!

**URL:** https://forum.makecode.com/t/spaceshooter-game-bugs/10088
**Category:** Help
**Created:** [September 17, 2021, 8:38pm UTC](https://forum.makecode.com/t/spaceshooter-game-bugs/10088 "2021-09-17T20:38:24Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Camaro](https://avatars.discourse-cdn.com/v4/letter/c/977dab/32.png) [@Camaro](https://forum.makecode.com/u/Camaro)
#### Post date: [September 17, 2021, 8:38pm UTC](https://forum.makecode.com/t/spaceshooter-game-bugs/10088/1 "2021-09-17T20:38:25Z")

</div>

Please help!! I’m making a space shooter game and encountered some bugs.

There are 3 kinds of power-up in this game. 2 of these are powerups that improve the rate of fire on projectiles that can stack with each other:

Projectile powerup 1 = Doublefire  
Projectile powerup 2 = Tripplefire

The 3rd one is a laser that can be used when pressing A:

Laser

BUG 1: When 3 projectile powerups are on the screen at the same time, once I get to stack the 2 different projectile powerups, the remaining 3rd powerup on the screen will not be destroyed in contact with mysprite.

BUG 2: When I get a laser powerup, an indicator regarding the laser will show up on the side of the screen. When I press A, mysprite will shoot laser and the indicator will disappear. However, if I have a laser power up and then got another laser powerup, once I press A, the indicator will not disappear.

Also, I need suggestions about how can I make the enemy shoot projectiles in the direction where my sprite is.

Thanks!

> **[Spacefort v0.2](https://arcade.makecode.com/81208-15332-08517-57650)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

### Author: ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)
#### Post date: [September 17, 2021, 9:15pm UTC](https://forum.makecode.com/t/spaceshooter-game-bugs/10088/2 "2021-09-17T21:15:10Z")

</div>

Oh wow! This is a _beautiful_ game!

I’m heading out for the evening, but I definitely will take a look at this over the weekend.

You have a lot of code, so it will take some time to get through all of it.

When I run into bugs in a complex program like this, I try to disable everything that does not apply to the bug. So, if you are debugging the powerups, disable the code that creates enemies so that you can focus your attention just on the code for the powerups. (Disable blocks by dragging them out of, say, the `forever` block where they are contained. Disabled blocks are shown in lighter colors. It looks like you already know how to do that.)

Good luck! Great game!

---

<div class="post-metadata">

### Author: ![Camaro](https://avatars.discourse-cdn.com/v4/letter/c/977dab/32.png) [@Camaro](https://forum.makecode.com/u/Camaro)
#### Post date: [September 17, 2021, 11:43pm UTC](https://forum.makecode.com/t/spaceshooter-game-bugs/10088/3 "2021-09-17T23:43:51Z")

</div>

Thank you so much for your response.

I really need help because I’m now stuck with these bugs aheheh 😅

I will try to disable the blocks that are not related to these bugs.

Anyways, I actually made some visual improvements to the game while I’m thinking of a solution::

> **[Spacefort v0.2.1](https://arcade.makecode.com/92625-05259-64752-56611)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

### Author: ![Primal\_Nexus](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/primal_nexus/32/3540_2.png) [@Primal\_Nexus](https://forum.makecode.com/u/Primal_Nexus)
#### Post date: [September 18, 2021, 10:12pm UTC](https://forum.makecode.com/t/spaceshooter-game-bugs/10088/4 "2021-09-18T22:12:20Z")

</div>

Absolutely amazing game @Camaro, well done!

---

<div class="post-metadata">

### Author: ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)
#### Post date: [September 20, 2021, 3:58pm UTC](https://forum.makecode.com/t/spaceshooter-game-bugs/10088/5 "2021-09-20T15:58:14Z")

</div>

OK; I squashed your bugs. 🙂

> [@Camaro](#):
>
> BUG 1: When 3 projectile powerups are on the screen at the same time, once I get to stack the 2 different projectile powerups, the remaining 3rd powerup on the screen will not be destroyed in contact with mysprite.

For this one, you need to change your `on overlap` event handlers for `PowerUP`, `PowerUp2`, and `Shield`.

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/1cb8daf6773a76e5055d3756222ad67328e87d4d.png)

Because you might have multiple sprites of a given type on your screen, always use the `sprite` and `otherSprite` variables in your `on overlap` event handlers.

> [@Camaro](#):
>
> BUG 2: When I get a laser powerup, an indicator regarding the laser will show up on the side of the screen. When I press A, mysprite will shoot laser and the indicator will disappear. However, if I have a laser power up and then got another laser powerup, once I press A, the indicator will not disappear.

This one is a bit more difficult, but it’s a related problem. You may have multiple `Bomb` indicators on your screen, and you need to be able to handle that. I changed your `on button A pressed` event handler to look like this:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/610faa0fe12cc9cd3c12f2424ca7d080234acb3c.png)

Each time you touch a `Shield` sprite, an indicator is added to the screen. If you touch multiple `Shield`s, then you have multiple indicators. When you press the **A** button, the first indicator (or `Bomb`) is destroyed, leaving the other on the screen to be used later by the player.

The only other bug that I found was in your end game routine. Remove the call to `startLevel`.

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/0/0c2380c948e64cb2aa2360e6268dd7e2ae1039f5.png)

If you want to see how I went about debugging your program, feel free to take a look here:

> **[Spacefort v0.2.1 Debug](https://arcade.makecode.com/32857-18244-13260-29473)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Basically, I moved all of the code in your `forever` loops into functions, and then I only called the ones that I needed. (So, I removed all bosses and minions to focus on the power ups). I also moved the code where power ups are spawned into their own functions so that I could call that code whenever I wanted.

This is a really fun game! Nice work!

---

<div class="post-metadata">

### Author: ![Camaro](https://avatars.discourse-cdn.com/v4/letter/c/977dab/32.png) [@Camaro](https://forum.makecode.com/u/Camaro)
#### Post date: [September 20, 2021, 6:51pm UTC](https://forum.makecode.com/t/spaceshooter-game-bugs/10088/6 "2021-09-20T18:51:07Z")

</div>

Thank you so much! 😭 😄

You even made all these efforts and it really makes me happy

Here’s an update to the game and finally no more bugs 😄

> **[Spacefort v0.2.8](https://arcade.makecode.com/48137-10856-59089-37727)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.
