PyGameEngine Release 1 Now Available!

The source for PyGameEngine release 1 is now available at There is also a discussion topic there. The highlight of this first release is the camera class.
The camera class is designed to work seamlessly with the game class provided by the game engine. It allows you to focus on one point at a time. It comes with a useful function just for centering on a set of coordinates. It also can be constrained to not pass too far off the screen. There’s much more to come as well.

The project’s page is located at


I began work today on a new game engine for use with Pygame. Right now, it only has classes and functions to facilitate cameras and camera movement. There’s also a working demo for the camera class. It is in a pre-alpha version and has many known bugs. Including ones as simple as making a background larger than the camera. But it seems more stable than many other engines out there.

Here’s an example of a simple use of the game engine:

from PyGameEngine import *

class NewSprite(GameSprite):


def main():
background = pygame.surface.Surface((800,600))
pygame.draw.line(background, (255,255,255), (0,0), (background.get_rect().width-1, 0), 9)
pygame.draw.line(background, (255,255,255), (background.get_rect().width-1, background.get_rect().height-1), (background.get_rect().width-1, 0), 9)
pygame.draw.line(background, (255,255,255), (0, background.get_rect().height-1), (background.get_rect().width-1, background.get_rect().height-1), 9)
pygame.draw.line(background, (255,255,255), (0, 0), (0, background.get_rect().height-1), 9)

game = Game(screensize=(800, 600), caption="PyGameEngine testing", background=background, bgcolor=Color(40,0,0), backgroundfixed=False, fullscreen=False, maxfps=30, debug=True)

spritesurf = pygame.surface.Surface((32, 32))
testSprite = NewSprite(game, image=spritesurf, bounds=Rect(0,0, 800,600))
game.centerOn = testSprite
testSprite.centerOn(Rect(0,0, 800,600).center)
testGroup = GameSpriteGroup(game, [testSprite])
game.playersprite = game.groups[0].sprites()[0]

if __name__ == '__main__':

I will upload the source code as soon as I feel it’s ready. I may upload a video of the working demo though.

Multiple Python installations on one computer (Part 2)

Update: There is a possibly critical flaw with this technique. After setting this up, simply typing “ PARAMS” would not supply to params to sys.argv. Instead, I had to type “python PARAMS”. I will update with a fix as soon as I find one, but it may involve registry editing.

Update2: Make sure not to REPLACE your PATH variable, if you do, just add


to it and it should fix it. (This is for Vista)

In part 1 of this series, I showed you the basics of having multiple Python installations on one computer without spending too much time.

In this part, I will show some useful techniques for enabling easier use of your installations.

So I’ll start off by showing you the basics of installing several versions at once. The first step is to decide which versions you want, a combination of 3.x and 2.x is a good idea. Once you’ve decided this, you should go to their various pages on the python website. After downloading the installers, be sure to run them in order of [b]least used to most used[/b]. Meaning that if you want Python26 to be your main (default) installation, run the 2.6 installer last. This will add certain file associations (Most of which will get overwritten in later parts of this series anyway, but whatever).

Ok, now that we have that out of the way, we need to set up our Python environment. Notice that at this point, with a fresh Python installation, using


will run a python interactive interpreter with your “default” version. We’re about to add to that. The first step is to create a directory with a meaningful name that you can’t forget. I chose C:/cmds. Once you have your directory picked out, you need to run any text editor, even notepad will do. Now, add to the file the line:

C:\Python26\python.exe %*

(If you are running on a system older than XP, you can use a neat little trick which is to add a @ before the “C”, this mutes the output of this file.) If you are running a different version as your default, then change the version numbers accordingly (Or if you have them in completely different directories for that matter, just make sure it points to a valid python interpreter.) Now save this file as “python.bat” in your chosen directory. Next, make a new .bat file called “pythonw.bat” and add a ‘w’ to the end of the “python” in the exe.

Now, you shouldn’t notice any real difference, that’s ok, we’ll fix that soon.

Next, you should go to your control panel and go to the edit environment variables section. To get there, go to System>Advanced System Settings (On the left)>The Environment Variables button (On the bottom right). Now you will see a sort of complicated window with useful variables that Windows uses. Let’s not hang around here too long. On the top, there should be a “PATH” variable (Under user variables). Select it and choose “Edit”. You may want to take note of the current path before changing it for later. Now change it to your chosen directory (Not that you could have also just put your commands in the old directory, but the new one is in a place you can easily edit). Now go ahead and click OK here to accept your changes. Now if you go back to the command line and type the command “python” you should see that it opens an interactive interpreter with your “default” python version. Now that’s not all we’re going to do here.

Now what we need to do is add commands like:



To achieve this, we need to create some more .bat files in our directory. This part is pretty simple but can get repetitive. Start by opening up your original python.bat file and save it as a different version of Python. Example:


C:\Python26\python.exe %*

Now do the same for a “pythonw26.bat” file. (This time change “python.exe” to “pythonw.exe”)

If you have any more versions, do the same for them. You should end up with two .bat files for every Python version, which an extension to reflect the versions, plus two default ones with no version suffixes.

At this point, we’re done with the necessary stuff, but I’ve got a bonus for you! We’re going to be making it possible to use


instead of

It’s really unneeded, but can make typing in the command line easier later on.

So, to start, re-open that environment variables window you had open earlier. This time use the bottom panel and scroll down until you see the variable “PATHEXT”. This one we don’t want to completely override, instead, we need to append two things to it. To get an idea for just what you’re doing, look at the current contents. You will see that there are various file extensions in all caps separated by semicolons (“;”s). What we need to do is add the two extensions “.PY” and “.PYW”. When you’re done, you should have something like:


as the variable’s value. (Notice that your PATHEXT variable will likely be different from mine). Now click OK, open a new command line window (Did I mention that the changes won’t affect currently open windows?) and navigate to a python script. Try running it by just typing the filename minus the extension. It SHOULD work. If it didn’t work, you have a problem with file associations, which is a little more complicated than I think this already long post should go.

In Part 3, I will be addressing file extensions and setting their defaults, possibly with some more information.

Setuptools and easy_install

If you’re like me, then you encountered modules asking you to use


to install them. At first, it made no sense to me, but as I gained knowledge in Python, I finally understood it.

What you need to do is first install the scripts from PyPI. Go to and follow the simple installation instructions.

Once you have setuptools in your Python Scripts folder, you are meant to be able to simply call

easy_install <PACKAGE>

from the command line, but for some reason this didn’t work on my machine. Instead, I had to navigate to my Python installation directory’s scripts. for me it was


Once in this directory, you can either type just

easy_install <PACKAGE>


easy_install.exe <PACKAGE>

depending on your preference.

Now let’s test our new installation of setuptools. Open up a command line and navigate to your Python Scripts directory, then type:

easy_install pygame

(No worries, this should not harm your pygame installation, in fact it may help you!)

You will get some output similar to:

C:\Python26\Scripts>easy_install pygame
Searching for pygame
Best match: pygame 1.9.1
Adding pygame 1.9.1 to easy-install.pth file

Using c:\python26\lib\site-packages
Processing dependencies for pygame

Note that if you do not already have the latest version of the chosen package, it will ouput a little more.

Basically what this program does is check the PyPI (Or cheeseshop) for your selected package. If it finds it, it scans the dependencies and files for it and installs them. If not, it looks harder and usually fails.

In case you see a module for Python that says it is on the PyPI, you can try using easy_install before manual installation, it really is easy.

Multiple Python installations on one computer (Part 1)

So, I now have four different Python installations running at the same time, they are:

Python 2.5

Python 2.6 (My preference)

Python 2.7a

Python 3.1

So far, I have not met any problems on this setup, except for a slight pain. .py files and friends are all associated with Python 2.6, which is what I want, but the “python” command line command is associated with Python 2.5. So, if I want to run a program in 2.5, I just type the python prefix, else, I just type the filename. There seems to be no real benefit nor drawback to having multiple installations as you will most likely end up only using one anyway. Even so, if you can properly manage your installations, I recommend having a setup similar to my own.

Keep in mind I’m still working this out, once I get it, I’ll be sure to post an update with the new info.
I also plan on making this into a series with useful info about this.