Microsoft MakeCode

Power Up Man v1.0

This might have a bug but i think it’s still cool to play. Press Z(aka A) to fire, Press X(aka B) to charge your energy, and hold Z to fire a beam. At 100% charge you can fire and insta kill shot by pressing Z.

:heart:Enjoy! :heart:

2 Likes

I like how you can charge the player to fire off an ‘insta kill’. Some enemies stay on the screen after hitting the wall, while others disappear. I saw that they are meant to be destroyed after hitting a wall but it is not always happening.

1 Like

Yeah, i’m thinking of adding a back wall to see if that works. Also for some reason sometimes when i shoot an enemy the game will come up with an error that says ‘failure to call on null’ I’m glad it works for everyone else cause i have no idea how to fix it.

1 Like

I think this has to do with this block.
image

If I understand this extension correctly, this event fires when the enemy’s health reaches zero, so you can decide what to do with the enemy. However, you are simply deleting a reference to an enemy sprite that was created in the game update loop.

So I am guessing when another piece of code is accessing an enemy sprite somewhere, that maybe that reference no longer exists.

I think what you need to do is this:
image

You set a reference to the sprite whose status bar has reached zero, and then delete it. Give that a try and let me know how that goes. If you are unsure, you could ask @jwunderl as he made and/or announced the extension: Status Bars extension (beta)

2 Likes

I think I might have found the bug. When you debug the game, even when it is in blocks, it shows the piece of code that went wrong:

Whenever you use an event block function, you need to reference the variables within the function, and not variables that are declared in global scope. What I mean by global scope, those are variables that are defined within ‘game start’ for instance. For example:

Notice how I replaced ‘projectile1’ with ‘sprite’ (this is of kind Projectile), and the global variable ‘otherSprite’ to the variable from the function.

However, you have three different types of projectiles that do different types of damage. So just using the variable in the event, you don’t know which type it is. What you could do, is attach data to the projectile sprites, like 1, 2, 3, get the data of the sprite in the event, and then in the ‘if’ statement determine how much health is taken from the enemy.

Does this make sense, or have I flooded you with too much information? Let me know if this is too confusing and I can help you fix the bugs.

1 Like