Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 4 down vote accepted

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.

share|improve this answer
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. – David Gouveia Dec 30 '11 at 14:33
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). – George Duckett Mar 7 '12 at 9:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.