Jumping on Enemies to Zap them

Jumping on Enemies to Zap them

How to implement this Pattern in MakeCode

Add a Condition for the Overlap Listener block

We want the enemy to zap the player if they overlap normally or if the player is jumping up. But we want the player to zap the enemy if they are travelling on the down part of their jump.

To do this we will check the Player’s x axis velocity. As the numbers are measured from the top of the screen going down, if it is greater than 0 then the player is travelling in the down direction.

Check if that’s true using the code blocks below, and if that isn’t the case then set the game to game over.

Jumping on Enemies to Zap them

The blocks in the else section may be different for example if you are using player lives, you will want your player to lose a life instead.

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.