How to debug Pygame application with Visual Studio during runtime
<p>I've been making a small game for a homework assignment using Pygame with Livewires. I've been trying to debug it, but to no success; I can't get a look at the variables I want to look at before the main loop is executed. Though I can press F10 to skip over the main loop, that just stops the Autos and Watches window from working; apparently they can only records vars when the game is paused by the debugger. </p>

<p>Is there a way for me to use the debugger to look at the vars in runtime? Because no matter what I do while the debugger is paused, I can't look at the data inside the game objects I want to take a look in</p>

<p>Thanks to Jack Zhai's suggestion, I figured it out. </p>

<ol>
<li><p>When the breakpoint is hit, unpause the debugger (shortcut: F5)</p></li>
<li><p>Play to the point in the game you want to debug.</p></li>
<li><p>Repause the debugger using Break All (shortcut: Ctrl-Alt-Break)</p></li>
<li><p>Press F10 a few times; this makes it go a few more steps in the main livewires loop.</p></li>
<li><p>In the autos window, there is an entry that contains the a list of the game's objects. Look through it, until you find the one(s) you're looking for. In my case, the list of the objects was self._objects. The object I was looking for was the second, which in other words, was self._objects[1].</p></li>
<li><p>The dropdown arrows of the object(s) you're looking for show the object's members.  If you want to look at the object's properties in a less cumbersome way, use the Interactive Debugger to assign that object to a variable. That way, you can look at its values through typing objectNameHere.objectValueHere into the interactive debug console.</p></li>
</ol>

<p>In my case, I had to type in player = self._objects[1] to get it assigned, then could see the player's x position by then entering player.x into the debug console.</p>

<p>--</p>

<p>I know this answer might only work for my specific problem, so if anyone else has a better one, please post it for others' sake.</p>

python visual-studio debugging pygame livewires