I am trying to learn pygame. In order to do that, I have downloaded one of their examples :


And started to run it in debug mode.

However, I have discovered quite quickly that unlike a classic program, it is hard to debug a computer game, because of the fact that it is hard to control the player by sending keyboard press events.

Any suggestions?


1 Answer 1


A couple of things that I do when debugging games:

  1. Use a console to output relevant information.
  2. Output debug data directly on top of your game screen.

Since you are dealing with a game loop, breakpoints are sometimes quite difficult to use when debugging such things as character movement. Displaying the data you want to verify on screen while you are moving your character is a great way to visually see what is happening behind the scenes.

  • 1
    \$\begingroup\$ Yet, breakpoints are still useful in a multitude of game situations such as when you want to check why some specific part of your code is not working. I use breakpoints all the time, so don't disregard them as a tool for debugging in games. \$\endgroup\$ Dec 30, 2011 at 14:33
  • 1
    \$\begingroup\$ I'd also add that in some languages (don't know about python) you can set breakpoints to be triggered only when a certain condition is true, which can also help (for example set up a key press to change a variable, which makes the breakpoint trigger so you can step into a constantly running function at a specific point in the game). \$\endgroup\$ Mar 7, 2012 at 9:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .