Name: Jumping on Enemies to Zap them
Description: In many games players shoot enemies. In some platformers they get rid of them by jumping on them instead. If the player is descending from a jump when they touch the enemy the player is zapped and in this case disappears.
Need for Pattern: Being able to jump on an enemy is a good way of clearing the area you want to explore. You may need to have a clear space to be able to jump up to a high platform for example. Some platformers do have a shooting mechanic as well but using this pattern and sticking with jumping also keeps the game simple (in a good way).
Coding Concepts involved: Data, Change Listener
Links to other Computing Patterns: Systems Dynamics,
Related Game Patterns: You’ll need to have added the Add Enemies pattern to your game before you can add this one.
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.
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 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.