#codersToolbox
Explore tagged Tumblr posts
pico-8-update · 5 years ago
Text
Debugging tips - part 1
Tumblr media
This will be a series of posts for coders looking for tips on debugging their carts on runtime.
Let’s start with the basics...
Essentials: RESUME
This might be very basic knowledge, but it surprised me when I found out: If you press Escape after running your game with RUN, you are thrown back to the command line; If you use the command RESUME, the game will continue running where it left off, as if it was just paused (well, kind of- it calls a new frame in the _UPDATE() game loop).
You can run code in the prompt as usual, but here is the tip: you can use the variables with the values as they were left by the game state when it was interrupted. This means you can PRINT their values or modify them and resume to test without editing the actual code. You can change values to quickly test things without having to run the game from the beginning up to that point. Neat!
Old School: PRINT() everywhere
An old time classic, fill the code with PRINT statements to see if that part is reached in runtime, or to see the value of a variable as it changes in realtime.
A good way to do this in a game loop is to save the variables you want to debug in another variable in your _UPDATE() loop, and print them in your _DRAW() loop.
You can even get fancy and save them in a table, to then print them in multiple lines, having a sort of debug watcher on a corner of your screen.
Community made tools
There are different solutions made by members of the pico-8 community that range from simple to complex. This is a list of PNG carts and their respective links to their BBS threads (remember that you can download these images as .p8.png files and load them in your pico-8 machine!)
Let’s have a look:
Tumblr media
VDMP: var_dump to “pretty print” a table. bbs thread
Tumblr media
Die n’ Dump: stop execution and “pretty print” a variable. bbs thread
Tumblr media
Variable Inspector: Adds a popup to your game that lets you traverse complex tables like an unfoldable tree. Amazing! bbs thread
Tumblr media
Debugging Tools: feature-rich debugging hud. bbs thread
Tumblr media
Super Debug Menu: Press the tilde key during runtime to show an overlay with lots of debugging and performance info. Superb! bbs thread
...And that is all for this part of Debugging Tips. I will be surely trying out all of these snippets and tools and pick a favorite!
In the next part we will be looking at performance testing and CPU profiling. Cheers!
1 note · View note