Microsoft MakeCode

THAAD, a missle command game

Made in blocks


arcade-Thaad

Update:

2 Likes

This is really, really good :smiley:

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

to this:

16%20PM

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

1 Like

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!

1 Like

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 :slight_smile:

3 Likes

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!

2 Likes

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

1 Like