Debug it with code

Find and fix the errors

The previous page explained how some of the main game loop worked. You’ll have to look at the comments in the code to work out what the rest of it does.

Below is a deliberately broken version of the doodle jump game for the BBC micro:bit. See if you can find and fix:

  • A syntax error that is stopping the code from running at all

  • A runtime error that occasionally makes the game crash

  • A logical error that makes the game pretty unplayable because it runs so slowly.


Hint: If you’re stuck, you can compare the code above with the code on the first page to see where the errors are. Try to work out what is actually going wrong and why, rather than just copying and pasting the working code.

On the final page, there are some suggestions on how you can extend and improve this doodle jump game for BBC micro:bit.