# THAAD, a missle command game

**URL:** <https://forum.makecode.com/t/thaad-a-missle-command-game/556>\
**Category:** Arcade\
**Tags:** game\
**Created:** [September 20, 2019, 11:09pm UTC](https://forum.makecode.com/t/thaad-a-missle-command-game/556 "2019-09-20T23:09:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlj1978](https://avatars.discourse-cdn.com/v4/letter/j/dbc845/32.png) [@jlj1978](https://forum.makecode.com/u/jlj1978)\
**Post date:** [September 20, 2019, 11:09pm UTC](https://forum.makecode.com/t/thaad-a-missle-command-game/556/1 "2019-09-20T23:09:56Z")

</div>

Made in blocks

> **[Thaad](https://arcade.makecode.com/37763-80752-96162-08238)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

  
 ![arcade-Thaad](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/1X/eaa28b6eb5379e4b2492df5aad54ca2ebff16ca7.png)

Update:

> **[Thaad](https://arcade.makecode.com/58384-01813-46310-56288)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [September 20, 2019, 11:16pm UTC](https://forum.makecode.com/t/thaad-a-missle-command-game/556/2 "2019-09-20T23:16:05Z")

</div>

This is really, really good 😃

edit: really really minor thing, the `lifespan` property of a sprite helps destroy things after a certain amount of time (you can get it by dragging out `set mySprite x to {}` and changing the drop down) - in particular, changing this:

![43%20PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/1X/cf3cc4a589eab3ce14f99a9d39e54b6de5f2fe23.png)

to this:

![16%20PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/1X/a0f9c722cd8c1a6515fc2054bb89365b2142871f.png)

will fix a minor bug where firing too fast can leave the explosion on the screen indefinitely. But yeah, this is really cool!

---

<div class="post-metadata">

**Author:** ![jlj1978](https://avatars.discourse-cdn.com/v4/letter/j/dbc845/32.png) [@jlj1978](https://forum.makecode.com/u/jlj1978)\
**Post date:** [September 21, 2019, 11:03am UTC](https://forum.makecode.com/t/thaad-a-missle-command-game/556/3 "2019-09-21T11:03:36Z")

</div>

Thank you very much. I had wracked my brains and limiting the firing rate was the best I could do. That only eliminates the indefinite explosion most of the time, but it still happens. I don’t understand why it happens, but at least now I can fix it!

---

<div class="post-metadata">

**Author:** ![NightIsland](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/nightisland/32/349_2.png) [@NightIsland](https://forum.makecode.com/u/NightIsland)\
**Post date:** [September 21, 2019, 8:03pm UTC](https://forum.makecode.com/t/thaad-a-missle-command-game/556/4 "2019-09-21T20:03:56Z")

</div>

As for the why it happens and why that fix works; it’s because the SpawnBurst function gets called and is running through the code, and then it gets to the pause command; the rest of the game carries on running, and if another explosion is caused, SpawnBurst gets called a second time, and suddenly the global variable THAADburst is overwritten with a new instance of the Weapon sprite.

When the first function call then resumes execution, the global variable THAADburst is now pointing to the instance that was created in the second call, so it destroys the second one, leaving the first one orphaned, with nothing pointing to it, and no way to get rid of it.

The fix works because it sets the instance to destroy itself, and so no further pointer to it needs to exist.

A classic multi-threading issue 🙂

---

<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 21, 2019, 8:10pm UTC](https://forum.makecode.com/t/thaad-a-missle-command-game/556/5 "2019-09-21T20:10:26Z")

</div>

This is great! I love the graphics and the animations! I particularly like how the launcher changes orientation based on the cursor’s position. Really nice take on a classic video game. Nicely done!

---

<div class="post-metadata">

**Author:** ![jlj1978](https://avatars.discourse-cdn.com/v4/letter/j/dbc845/32.png) [@jlj1978](https://forum.makecode.com/u/jlj1978)\
**Post date:** [September 22, 2019, 1:10am UTC](https://forum.makecode.com/t/thaad-a-missle-command-game/556/6 "2019-09-22T01:10:15Z")

</div>

Thank you very much for the explanation–that will come in handy in the future.
