Remixing a Platformer Game - Random Doubling Enemies

random doubling enemies

How to implement this Pattern in MakeCode

Create our Random Enemy

We will create our randomly appearing enemy by creating a forever loop which creates an enemy of a type projectile that starts at the side of the screen and moves left. So the enemy doesn’t always start in the same place we will make the height value (y) random. See the screen shot below. Add in a pause to the forever loop so it this new projectile happens every 5 seconds to start with.

random doubling enemies

We now code a listener event that creates game over if there is an overlap.

random doubling enemies

Increase Spawn Time

A common pattern is to increase the spawn time of our enemies to increase the challenge. To do this we will first create a new variable at the start of our game called spawnTime. Replace our value in the previous fover loop with this variable.

random doubling enemies

We now need to start to decrease this spawnTime variable. One easy way of doing that is to half the value every time the event runs by dividing it by two. This creates a reinforcing feedback loop so things might get crowded with projectiles very soon.

random doubling enemies

Your player will have to be fast.

Test your Changes and Next Steps

Test your game to check that your changes have the desired behaviour and that there are no side effects.

To check that you are making the most of this pattern you can ask yourself the following questions:

This Game Pattern is one of many allowing you to make improvements to your platform game and to learn coding and wider computing concepts. Find more on the Game Pattern page.