Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What can Pygame do in terms of graphics that wxPython can't?

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.

like image 811
Eli Bendersky Avatar asked Dec 05 '08 11:12

Eli Bendersky


People also ask

Does pygame have graphics?

To make graphics easier to work with, we'll use “Pygame.” Pygame is a library of code other people have written, and makes it simple to: Draw graphic shapes. Display bitmapped images.

What is the difference between pygame and tkinter?

First, tkinter is definitely not the best GUI toolkit for python. It's one of the simplest and usually comes with the python interpreter. But it's not as powerful as Qt, wx or Gtk. pygame is - as it's name states - a package designed to allow to create games in python very easily, not to create GUIs.

Can you use pygame as a GUI?

Pygame GUI is a module to help you make graphical user interfaces for games written in pygame. The module is firmly forward looking and is designed to work on Pygame 2 and Python 3.

Can pygame make 2d games?

Pygame supports only 2d games that are built using different sprites. Pygame is not particularly best for designing games as it is very complex to use doesn't have a proper GUI like unity but it definitely builds logic for further complex projects.


2 Answers

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.

like image 167
Manuel Ceron Avatar answered Sep 25 '22 19:09

Manuel Ceron


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.

like image 26
Berufsstudent Avatar answered Sep 22 '22 19:09

Berufsstudent