Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between Python game libraries Pygame and Pyglet?

I've had some experience with Pygame, but there seems to be a lot of buzz around Pyglet these days.

How do these two libraries compare? What would be the advantage of using one over the other, both in features and ease of use?

Finally, would you say that one is more Pythonic than the other?

like image 397
nakedfanatic Avatar asked Dec 16 '08 07:12

nakedfanatic


People also ask

Which is better pygame or Pyglet?

Ans:- Speed-wise, Pyglet is definitely faster than pygame and has better performance, and nowadays speed is always a concern when developing with a game.

What is the difference between Python and pygame?

Python is an interpreted general-purpose programming language. It consists a lot of modules/libraries for different purpose. One such library is Pygame. Pygame is a library consisting a set of modules which are used to write programs for video games.

Is there anything better than pygame?

Kivy, Blit, Godot, Electron, and Unity are the most popular alternatives and competitors to pygame.


1 Answers

I was considering both Pygame and Pyglet for a small 2D shooter, and after looking at source code and some tutorials went with Pyglet. I was very happy with the results.

Pyglet worked immediately and was enjoyable to work with, and conceptually very clean. It certainly had a Pythonic feel to me: you could get a straightforward and readable example going very quickly, and it uses decorators to good effect for event handling. It also didn't force a particular program structure, which made it easy for me to mix in the physics modelling of Pymunk (http://code.google.com/p/pymunk/).

While it is based on OpenGL and you can use those features for special effects, I was able to do just fine without any knowledge of them.

It also works well with py2exe and py2app, which is important because a lot of people do not have a Python interpreter installed.

On the downside, there is less information about it on the web because it is newer, as well as fewer sample games to look at.

Also, it changed quite a bit from previous versions, so some of the tutorials which are there are now out of date (there is the "new style event loop" and the Sprite class as major additions.)

I would recommend downloading the examples (there is a nice Asteroids clone called Astraea included) and seeing if you like the style.

like image 120
Kiv Avatar answered Sep 19 '22 20:09

Kiv