Microsoft MakeCode

Creating levels and end boss

I’m in the process of creating a top down space shooter. I have an array set to throw asteroids at he player. However, once they get through that part I want to have them fight a boss. Once defeated, they progress to the next level.

Is this possible? So far I can’t quite figure out how to set up levels. I’ve seen an array of levels for a side platformer, but not something like a space shooter. Any tips would be grateful! :slight_smile:

1 Like

There isn’t a “built-in” way to do multiple levels, it really depends on the game. A good place to start though is to break your program into functions. For example, have a function for creating the player, have a function for adding enemies to the game, etc.

Then, create a function that “cleans up” in between levels. That usually means deleting all of the sprites in the game, and there is a very useful block for doing that in the “Arrays” category that gives you a list of all of the sprites of a certain kind. For example, if I wanted to delete all of the enemies I might do this:

Once you have that, you can call your create functions to start a level and your cleanup functions to end it. You could have one function per level, or do what the platformer does and have a function that takes an image and places enemies on the map where certain colors are.

I hope that helps!

2 Likes

For the boss part, I think you should have a variable, that increases by 1 each level they beat. This counter can be used to dictate things that happen, like a boss, or harder levels. It’ll be 0 at the start, and go up from there.

1 Like

Brilliant idea! This is why the community here is so helpful. It makes complete sense. Use functions to clear the screen and change up the enemies with the illusion of levels. My next hurdle will be, the best way to ‘trigger’ the function - at the moment, I’m thinking of using an ‘On Game Update 40000ms’ to have the next function triggered after 40secs for example, but then it will do that ever 40 secs which I don’t particular want - any other creative ways of doing this? Is there a way to trigger an event other than after a time period?

3 Likes

Great idea! I need to determine how to add health to a unit that decreases by 1 after each hit. Makecode Arcade is a new learning curve for me but so far i’m enjoying it!

You could trigger the new level function off of any event; one that might be helpful would be based off when a certain number of enemies are destroyed. For example, you could say ‘when a certain number of enemies have been destroyed, create a boss and stop spawning enemies; then move onto the next level when the boss is destroyed.’ This can get a bit complicated, but here’s a snippet of one approach to creating that sort of behavior:

This will create a boss after 5 enemies have been destroyed on the first level, then 15 for the next level, and so on. (I also added a lifespan to the example below so that it will destroy the boss and continue after a short time)

4 Likes

Hey Jwunderl! Thanks for the snippet of code! I had a helped! I’ve been able to set it so after 15 asteroids are destroyed, it spawns the boss. I’m going to pick your brain so see how deep it can make this little side project to go.

I’m thinking about allowing the user to select 3 different ships at the beginning of the game, essentially 3 different sprites. Is this possible? Are their any project like that at the moment where a sprite is an some form of array, the user selects that sprite that would be utilised throughout the code?

Secondly - Is there a way to put pictures or colour behind a splash screen? Normally it’s all black but I’m trying to think of a creative way to do pixel art cut scenes to see if some kind of storyline is possible. Again, thanks for the visual help with the code! Appreciate all the effort. I’ve attach my code thus for people to look at. Eventually I’ll change the sprite of the ship to an original with animation of flames coming out the back but just trying to get the mechanics working. So far it goes as far as spawning the cake (boss) but that’s it for now.

arcade-T4L-Harrier%20V2

1 Like

For selecting your ship, take a look at the Memory game in MakeCode Arcade. You can find it in the Blocks Games section.

Because it’s a rather common construction (John Park uses something similar in his racing game, too), I created an extension to simplify this. If you’re interested, then take a look at this thread for more information:

Nice work so far!

Don’t worry it’s new to me too!

for cutscenes, you could set the background image, then set long text bottom for dialogue between characters.I used this before for ending dialogue in my own game

You will find a new extension “storyboard” in /beta that allows to do full scenes, boot sequences, etc… that might help with level creation.

2 Likes

Ok actually have found it. Didn’t have the /beta in my editor. Anyone have an example on how to use the storyboard feature? AKA what it looks like in code?