# Help with projectile-based game

**URL:** <https://forum.makecode.com/t/help-with-projectile-based-game/33041>\
**Category:** Help\
**Created:** [January 8, 2025, 11:46pm UTC](https://forum.makecode.com/t/help-with-projectile-based-game/33041 "2025-01-08T23:46:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Snoopytaco12](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@Snoopytaco12](https://forum.makecode.com/u/Snoopytaco12)\
**Post date:** [January 8, 2025, 11:46pm UTC](https://forum.makecode.com/t/help-with-projectile-based-game/33041/1 "2025-01-08T23:46:47Z")

</div>

My game is here [https://arcade.makecode.com/S11684-46433-22543-72372](https://arcade.makecode.com/S11684-46433-22543-72372)  
It is a sci-fi shooter game but you can only shoot while you are moving. Can anyone help me debug this?

---

<div class="post-metadata">

**Author:** ![Don](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/don/32/17989_2.png) [@Don](https://forum.makecode.com/u/Don)\
**Post date:** [January 13, 2025, 6:14pm UTC](https://forum.makecode.com/t/help-with-projectile-based-game/33041/2 "2025-01-13T18:14:30Z")

</div>

The first change you should make is not having a variable for each alien. It looks like all the aliens are the same so there is no reason to care about them individually. That change removes about 75% of the code.

Use event handlers. Instead of having a forever loop watching for an alien to die handle it in the event handler.

You also have a forever loop watching for the A button to be pressed. Move that code to the A button event handler.

Make those changes first. You may find everything is working. Right now you have so many variables and flags that a bug is unavoidable.

---

<div class="post-metadata">

**Author:** ![Fryguy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/fryguy/32/19336_2.png) [@Fryguy](https://forum.makecode.com/u/Fryguy)\
**Post date:** [January 14, 2025, 6:22pm UTC](https://forum.makecode.com/t/help-with-projectile-based-game/33041/3 "2025-01-14T18:22:44Z")

</div>

The other issue is your forever loop:

 ![IMAGE](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/c/0/c0bda242d6a3f2697ad91577e691f40b6e12a7f9.png)  
The “velocity x” code measures speed and direction  
Hence, using just “x” should work  
Hope this helps!

---

<div class="post-metadata">

**Author:** ![Snoopytaco12](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@Snoopytaco12](https://forum.makecode.com/u/Snoopytaco12)\
**Post date:** [January 30, 2025, 11:52pm UTC](https://forum.makecode.com/t/help-with-projectile-based-game/33041/4 "2025-01-30T23:52:01Z")

</div>

Thanks a lot, I appreciate it!

---

<div class="post-metadata">

**Author:** ![Snoopytaco12](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@Snoopytaco12](https://forum.makecode.com/u/Snoopytaco12)\
**Post date:** [January 30, 2025, 11:52pm UTC](https://forum.makecode.com/t/help-with-projectile-based-game/33041/5 "2025-01-30T23:52:03Z")

</div>

Thank you for this! I’ll make sure to change this, I appreciate it!
