Debugging a running game
Until now, we have been able to debug our game by printing values to the output console. This is a very quick and effective way of debugging, but there are actually more options available that can shed way more clarity on what is happening during our game’s execution.
Let’s look at these ways in detail.
Breakpoints
The first, and most classic way of debugging is by using breakpoints. A breakpoint literally breaks, or halts, the program at the line of code in which the breakpoint was put. To place a breakpoint, click next to the line number of a line of code within the code editor.
Figure 7.21 – Adding a breakpoint in the code
When the interpreter comes over this line, and thus this breakpoint, it will stop everything and show you where the execution of the code is.
Try it out by placing a breakpoint in the _physics_process()
function of the player. Once the program halts, the Debug panel will unfold...