Hunting Bugs — Debugging and Troubleshooting in MakeCode Arcade

Kiki Prottsman
Kiki’s Corner
Published in
3 min readMar 7, 2022

You might not think that hearing “Oops!” is a positive thing, but in computer science, we love it. Why? Because “Oops!” means there’s been a mistake, and mistakes lead to learning.

Imagine this. It’s late at night, and you think you’re almost through with your game. You save a copy (just to be safe) then switch to the largest view to play your creation…and it doesn’t work!

We’ve all been there — but if you’re looking for ways to make sure your game is playable as soon as possible, keep reading.

Test Often

The #1 tip I have for new coders is “Test Often!”

It’s much easier to find errors in your code when you remember the last point when it worked. That is to say, you should check your program after every 1–2 lines of code you add. That way, if you find an error, you know it’s located in the last couple of lines that you changed.

Where Does It All Go Wrong?

If you’re having trouble narrowing down an issue, try asking yourself, “Where does it all go wrong?”

If it works fine until a certain spot, chances are that the issue with the code originates either at that spot, or in a function/variable related to that spot. Try describing out loud what’s working and what’s broken. Some times, when you hear yourself describe the point that things stop working, the fix becomes clear.

Send Messages

Another very helpful trick is to send messages to yourself from inside the code. Not sure if a conditional or event is triggering? Add a sprite say block or a console log block so that you have a visual record of which blocks are getting triggered.

Adding sprite say and console log blocks
Adding sprite say and console log commands
The result of running a program with sprite say and console log commands
Seeing the list of values that have been logged to the console

Use the Step-Debugging Features

Need more detail?

Toggle to the step-debugger by clicking the bug icon in the teal menu below the game window. This will open a tool that highlights each block of code as it’s run, letting you see exactly what’s happening.

Click the bug icon in the teal menu bar to open the step debugger
The debugger window highlights each block as the program runs it so you can see what features are getting run and which are getting missed.
A similar screen for those coding in text

Get a Fresh Pair of Eyes On It

If you’ve hit this point and you still don’t know where things went awry, you probably need a fresh pair of eyes. Try either asking a friend to look at your code, or going for a walk. Sometimes, coming back to your problem a couple of hours later lets you see the issue much more clearly!

Do you have a tip or trick for finding bugs in your code? Leave a comment below and let us know!

--

--

Kiki Prottsman
Kiki’s Corner

Kiki is an author, educator, and the Director of Education for Microsoft MakeCode