Making Games with Python: Which Library To Use, pygame or pyglet?

Python is a simple yet powerful programming language, and it is one of my favorite. Add to the fact that it has the powerful modules that focuses on providing the necessary utility functions to make a game!

I want to make exciting playable games, but I don’t think a one-person development can live with C/C++ 3D framework especially if the person is me, so I seek to make 2D games. In Python, at least there are two modules that can be used: pygame and pyglet (can’t they have any name not starting with ‘py’!?!?).

Python is a simple yet powerful programming language, and it is one of my favorite. Add to the fact that it has the powerful modules that focuses on providing the necessary utility functions to make a game!

I want to make exciting playable games, but I don’t think a one-person development can live with C/C++ 3D framework especially if the person is me, so I seek to make 2D games. In Python, at least there are two modules that can be used: pygame and pyglet (can’t they have any name not starting with ‘py’!?!?).

pygame: Solid 2D Game Framework

pygame is a thick-wrapper around an established game library for C, SDL. It provides high-level access to SDL functions (basically it adds up an object-oriented approach to those functions) and some spices. That means pygame has a complete set of functionality for games. SDL even has support for game CDs and joysticks!

The worst piece of pygame is that its development has been very slow. It might be pretty solid for some years (hey, there are already a lot of games written using it), but there are still useful features that can be added such as better sprite management and hardware acceleration. The last version was released about a year ago.

pyglet: Taking It More Lightly

By contrast, pyglet has a broader objective of being a multimedia library and a good wrapper for OpenGL. Being a wrapper to OpenGL means that it is bound to be alot better in 3D than Pygame, but it also means that it has no focus on 2D graphics. You can make 2D games with OpenGL, but it is rather clunky to have to learn about transformation matrices before being able to rotate the graphic of a spaceship. From what I can gather, however, there is work being done to add utility sprite functions such as rotate, flip, resize etc. (which will contain openGL calls) to pyglet.

pyglet also has a good event framework to work with, and provides multimedia support through AVBin, another Python library specialized for that thing. Also, since pyglet wraps most of its functionality around ctypes-wrapped OpenGL, pyglet is only coded in Python and has no external or C library dependencies.

It is also in active development, mainly because it is still young (the latest stable version is pyglet 1.0). Nevertheless, its is quite stable and useful judging from the examples it provide.

Contrasting It Up

That being said, there are areas at which pygame is better, and there are areas that pyglet much exceeds pyglet. The features that stand out most in pygame, IMHO, are:

  • great 2D sprite handling (usual rotate, flip, resize etc. functions, plus pixel access via NumPy for effects)
  • threading support
  • more evidence of use (there are already some games written for it, and most Python projects will refer to pygame for multimedia needs)

However, what I really like from pyglet are:

  • active development, at least for now
  • no C library dependencies, so you can distribute a game as Python modules
  • great hardware acceleration, since most work is done by OpenGL

Both libraries have satisfactory mouse, keyboard, timing, and multimedia features, so those do not make much difference.

Based on these, I would choose pyglet for future projects, as development on pygame has been slow. When coupled with a 2D sprite library utilizing OpenGL, pyglet can be a killer.

19 comments

Odd conclusion.

I find your remarks about active development to be odd. As you've said, Pyglet is in active development because it's new, and it needs to be. Pygame itself is stable; there's nothing wrong with it that it needs lots of work. Most of the development for it is in libraries or frameworks that sit on top of it, like Opioid2D which does OpenGL HW acceleration.

The dependency issue is a valid concern, but having packaged games made with Pygame myself, I haven't found it to be much of an issue in reality.

Mmmm... probably you are.

Mmmm... probably you are right about the development. It is just weird that a library like that is not being actively developed anymore. A lot of open source projects other than pygame are still developed even when they have about the same level of stability as pygame. SDL probably is more stable than pygame, but it is still developed. (Come to think of it, maybe a C library requires more maintenance effort than a Python library...)

Great piece of content! I.

Great piece of content! I will use that for my next targeted work out. Thanks a lot

Pygame has lost it.

As a switcher to Mac I have given up on Pygame. Its pathetic that its now June 19th 2008 and you have to fight tooth and nail to try and get Pygame working on your Mac OS X Leopard system.

Worse yet the only 1.8 release on the official site says go to Macports and build your own copy. That means download the last multi-hundred megabyte copy of OS X developer tools to get the latest version if you do not have it. Install macports, then search and if you are lucky you will find the port, its not returnable under pygame as a search parameter on the website. Then muck around for ages only to discover a Python 2.4 dependency.

Pygame can go to the place opposite of heaven, I'm switching over to Pyglet and using Rabbyt for sprite library instead of dealing with this 3rd class citizen treatment the Pygame community has given OS X users.

Cheezed off ex-Pygame developer.

I agree that platform.

I agree that platform support is important - anyone wants to play games regardless of operating systems. I checked out that rabbyt engine you mentioned just now, it seems to be a nice complement to pyglet and pygame! Thanks for sharing.

install python2.6 for mac and.

install python2.6 for mac and get pygame with easy_install

hi I am using the pygame, I.

hi
I am using the pygame, I think pygame is very stable and easy to use, but seems it is slow(I am a c++/java programmer and speed (frame rate) is very important for me).
I test the pyglet, I think pyglet has very nice design but it is unstable and the sprite (the most important element in 2D games) class of the pyglet is very simple.
I still using the pygame because pyglet seems unstable in the first test.
(I am a amature in game programming.)

For the 2D graphics you can. For the 2D graphics you can try "rabbyt":http://matthewmarshall.org/projects/rabbyt/ - theoretically its should work with any OpenGL-based libraries. I am also an amateur in game programming, nice to meet you! :)
Where are the comments?

There are supposed to be 6 comments to this post, but I can't see them.

EDIT: you can see them now ^^

Pyglet 1.1 is released /with/ nice spritesupport.

Hi!

Came across this page while searching for a comparison between pygame & pyglet. A lot of the comments here indicate a lack of sprite-support in Pyglet as being one of the largest issues with it.

A few days ago, pyglet 1.1 has been released, with a nice sprite-system. Haven't used it extensively yet, but looks pretty usable!

Pyglet looks the best.

ok, yes Pygame seems to be the best..for 2d..but, only 'cause it has the most time on it; pyglet, even though new, look like a good alternative for computer that lack in speed (aka: my computer). i like using SDL more over then anything else, it's simple and easy. but, pyglet also looks like it'll be better, and like the article said; it's lightwieght

Pygame is probably waiting, Pyglet grows on.

Pygame will probably become active again when SDL 2.0 finally shows up (it's been "in the making" for a long time since it's getting a lot of improvements, such as multiple windows).

Pyglet didn't start out as a 2d engine but it'll get better in that area eventually. It isn't an actual problem for experienced game programmers anyway, you get everything you need to make a decent sprite engine from OpenGL.

The only nuisance (that isn't inevitable like waiting for SDL 2.0) present in both of them is the lack of Python 3.0 conversions, however PGReloaded will be Pygame for Python 3.0, don't know about any plans for Pyglet. This nuisance is the problem with Python 3.0, the lack of libraries.

nodebox gl.

You might want to talke a look at nodebox gl http://www.cityinabottle.org/nodebox/. It's a drawing/processing-like framework built on top of pyglet. This allows you to utilize all of the pyglet functionality plus take advantage of a number of high-level drawing functions already written.

I like to check revealed your.

I like to check revealed your blog a three times a week also in behalf of new readings. I was wondering if you enjoy any other topics you indite about?
http://www.simplyrest.com/latex-mattresses

There are a number of things.

There are a number of things you can do to eliminate anxiety naturally without using medications. Bottom line is anxiety is caused by your negative THOUGHTS (either subconscious or conscious thoughts). read this

pyglet *has* external.

pyglet *has* external dependencies.

The website denies this, but many pyglet calls will fail if certain libraries are not installed.

Like pywin32 on windows for example, which is a pain in the ass to install, given that pip and easy_install don't know about it.

I think more updates and will.

I think more updates and will be returning. I have filtered for qualified edifying substance of this calibre all through the past various hours. Liga Inggris

Thanks so much with this.

Thanks so much with this fantastic new web site. I’m very fired up to show it to anyone. It makes me so satisfied your vast understanding and wisdom have a new channel for trying into the world. Bandar Bola

Stunning data of this blog!

Stunning data of this blog! The knowledge you distribute is insightful and encouraging to extend the senses. Thanks much
Bucky Barnes Jacket

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <pre> <i> <b>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.

Recent comments