views:

1285

answers:

2

Hello,

I want to develop a very simple 2D game in Python. Pygame is the most popular library for game development in Python, but I'm already quite familiar with wxPython and feel comfortable using it. I've even written a Tetris clone in it, and it was pretty smooth.

I wonder, what does Pygame offer in terms of graphics (leaving sound aside, for a moment) that wxPython can't do ? Is it somehow simpler/faster to do graphics in Pygame than in wxPython ? Is it even more cross-platform ?

It looks like I'm missing something here, but I don't know what.

+7  A: 

Well, in theory there is nothing you can do with Pygame that you can't with wxPython. The point is not what but how. In my opinion, it's easier to write a game with PyGame becasue:

  • It's faster. Pygame is based on SDL which is a C library specifically designed for games, it has been developed with speed in mind. When you develop games, you need speed.

  • Is a game library, not a general purpose canvas, It has classes and functions useful for sprites, transformations, input handling, drawing, collision detection. It also implements algorithms and techniques often used in games like dirty rectangles, page flipping, etc.

  • There are thousands of games and examples made with it. It will be easier for you to discover how to do any trick.

  • There are a lot of libraries with effects and utilities you could reuse. You want an isometric game, there is a library, you want a physics engine, there is a library, you what some cool visual effect, there is a library.

  • PyWeek. :) This is to make the development of your game even funnier!

For some very simple games like Tetris, the difference won't be too much, but if you want to develop a fairly complex game, believe me, you will want something like PyGame.

Manuel Ceron
+7  A: 

wxPython is based on wxWidgets which is a GUI-oriented toolkit. It has the advantage of using the styles and decorations provided by the system it runs on and thus it is very easy to write portable applications that integrate nicely into the look and feel of whatever you're running. You want a checkbox? Use wxCheckBox and wxPython will handle looks and interaction.

pyGame, on the other hand, is oriented towards game development and thus brings you closer to the hardware in ways wxPython doesn't (and doesn't need to, since it calls the OS for drawing most of its controls). pyGame has lots of game related stuff like collision detection, fine-grained control of surfaces and layers or flipping display buffers at a time of your choosing.

That said, graphics-wise you can probably always find a way to do what you want with both toolkits. However, when speed counts or you wish to implement graphically more taxing game ideas than Tetris, you're probably better off with pyGame. If you want to use lots of GUI elements and don't need the fancy graphics and sound functions, you're better off with wxPython.

Portability is not an issue. Both are available for the big three (Linux, OSX, Windows).

It's more a question of what kind of special capabilities you need, really.

Berufsstudent
And what if I want to use both ? I.e. have a graphic-full game and be able to control / configure it with standard GUI widgets ?
Eli Bendersky
You might want to consider displaying pyGame-graphics in a wxPython-Window. Try this link: http://wiki.wxpython.org/IntegratingPyGame
Berufsstudent
Yeah, I've looked at that before, but it doesn't look very comprehensive. The descriptions are somewhat reserved and doubtful, which is also what I found in other places.
Eli Bendersky