|Micro:bit Commando Jump Using MakeCode|
|Written by Sue Gee|
|Monday, 09 April 2018|
Page 1 of 4
The Micro:bit is quite a capable computer, but it does have one limitation - it only has a 5x5 LED matrix display. What sort of game could you possibly program on that?!
In this project we resurrect a classic BBC Micro game on the micro:bit. Games have always been a great way to get into programming and the micro:bit is no different.
Back in the days of the BBC Micro I was involved the development of a game called Commando Jump that was included in the book 21 Games for the BBC Micro. It was, by design, a very simple game intended to teach BBC Basic programming. It presented the player with a wall that the commando had to climb. The initial jump height was determined by the player's reaction time. After that they could make the commando scramble up the wall by pressing a key as fast as they could. The faster, the higher the commando climbed. If you reached the top of the wall before that time out then at the next level there was a higher wall. If you didn't make it the commando would slide down with a deflated noise.
A 5x5 LED display is just enough to implement this game. Not in all its many-colored glory but we can reproduce some of the original game play - and the temptation of re-implementing a game from the BBC Micro days on the BBC Micro:bit days was too good to miss!
In the rest of this article it is assumed that you know a little about programming and the Micro:bit.
Getting Started With MakeCode
Blocks For The Programmer
Working in a block editor can be frustrating if you are used to typing code as fast as you possibly can. The MakeCode Block Editor isn't as bad as you might think when you first start using it. Give it time and you will slowly find that you work out ways of doing things that avoid making a mess of your program as assembled so far by accidentally putting a block in the wrong place.
My advice when you are assembling a complicated set of blocks - a for loop say - is to not try to put it into the whole program until you have assembled it. Use another area of the editor as an assembly area and when you have the block complete move it into place.
Finally pay special attention to where you place one block within another - you can easily misplace one and discover that your code isn't within the for loop or if statement in which you wanted it.
What this means is that you have to create global variables to get data into and out of a function. This is not good news because this style of programming has long been known to be bad for anything but very small programs. Even a program as small as Commando Jump would benefit from being able to use parameters and return values.
It also has to be said that the error reporting could be better. For most of the time the blocks are a sufficient constraint to make sure that you can't make a syntax, or even a programming, error. The problem is that when you do the error message is usually something internal from the interpreter and it makes little sense even if you are an experienced programmer. You simply have to undo whatever you just did and hope it removes the error and then think very hard about what could be going wrong. The most common error is using something before it has been initialized properly.
It is important to realize that all of the variables you create are global.
So in this case Commando Jump is a game where a four-LED wall appears and the single-LED commando moves up one location for every ten presses of the button A. When it gets to the top, the commando sprite is animated horizontally and then down to its final position.
|Last Updated ( Friday, 18 May 2018 )|