This week in Advancers, Oliver was out so Mark covered. We built a platform game engine which will be really useful for powering all sorts of games and projects!
How did we build the game?
We did a list of the things we needed to happen and went through them one by one! The list was:
- Get gravity working so the hero could fall – we did this by creating a gravity variable and adding it to the speed each frame
- Get the hero to stop when he hits the ground – we did this by using a custom block to stay above ground – the run without screen refresh was needed in all our blocks to make them instant!
- Get the hero to jump – we did this by setting the hero’s falling speed to a number. We had to then figure out how to stop him from jumping when you hit jump and he’s in the air. We did this by making sure he could only jump when he was touching the ground.
- Get the hero to “bump” his head – this was very similar to how we got the hero to stay above ground – in fact, we changed the same block to do the same thing for him when he was rising!
- Make sure the hero can’t walk up really tall pillars – this bit was TRICKY and Mark had to scratch his head for a while to remember the best way. We got around this by setting a maximum height that he could climb over the ground.
I added some coins and death to the game to give an idea of how to use it.
The code is here for the main routine:
And the important “Stay above ground” custom block was here (remember to click the screen refresh option):
Lastly the tricky “Move” block which had the code to check for pillars: