Book Image

Instant Pygame for Python Game Development How-to

By : Ivan Idris
Book Image

Instant Pygame for Python Game Development How-to

By: Ivan Idris

Overview of this book

<p>Pygame is a library created to make multimedia software documenting easy to design. It adds functionality on top of the excellent SDL library. This allows you to create fully featured games and multimedia programs in the Python language. Pygame comes with functions and tools that will help you create a great user experience."Instant Pygame for Python Game Development How-to" is written in a concise and result-oriented format. Leading you through practical recipes, you'll find that this essential reference guide helps you to create visually appealing and thrilling games with a few clicks.This book starts with the basic instructions to install Pygame on different servers. It then goes into creating a sample game and explaining the features of drawing, animating, using fonts and Matplotlib with Pygame. The book then takes you through recipes to get access to some great sound and graphic effects. Giving you the steps to allow you to configure these games on Android and other networks, it ends with a walkthrough of the features of Sprites, OpenGL, and Simulation.</p>
Table of Contents (7 chapters)

Debugging your game (Intermediate)


Debugging is one of those things that nobody really likes, but is very important to master. It can take hours, and because of Murphy's law you, most likely, don't have that time. Therefore, it is important to be systematic and know your tools well. After you are done finding the bug and implementing a fix, you should have a test in place. This way at least you will not have to go through the hell of debugging again.

PuDB is a visual full screen, console-based Python debugger that is easy to install. PuDB supports cursor keys and vi commands. The debugger can also be integrated with IPython, if required.

Getting ready

In order to install puDB, we only need to execute the following command:

sudo easy_install pudb

How to do it...

To debug the collision demo code, type the following command on the command line:

python -m pudb collision_demo.py

Tip

The source code should be available for download from the Packt Publishing website.

The following screenshot shows the most important debugging commands at the top:

We can also see the code being debugged, variables, the stack, and the defined breakpoints. Typing q exits most menus. Typing n moves the debugger to the next line. We can also move with the cursor keys or vi J and K keys to, for instance, set a breakpoint by typing b.