Add a Static Enemy

mechanics add a static enemy

How to implement this Pattern in MakeCode

Add Static Enemies to your Tilemap

Click on your tilemap. Create a totally Red tile in My Tiles. Add one or two red blocks to your first level.

Static Enemy Block

You can also draw an enemy / hazard of your choice in My Tiles section. Click on the plus sign to do that.

Create a Collision Listener

We now code what happens when our player overlaps with our staticEnemy. Drag in an on sprite of kind player overlap with __ at location from Scene. Inside the block drag in from Game block of game over and keep it set to Lose.

Static Enemy Block

Test your game and Next Steps

Test your game to check that your changes have the desired behaviour and that there are no side effects. In this case check that each time you add in a red block in your level tilemap/s it should behave as a static hazard. When you touch the enemy the game ends with a Game Over message.

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.

As a next step you may find you want to increase the challenge even more perhaps by adding moving enemies. Or you may find that you want to balance out the increase of challenge that these hazards have brought and add player lives.