Python Library – PyGame

pygame logo

Download PyGame @ pygame.org

Informatie (ENG):

Pygame is a set of Python modules designed for writing games. Pygame adds functionality on top of the excellent SDL library. This allows you to create fully featured games and multimedia programs in the python language. Pygame is highly portable and runs on nearly every platform and operating system. Pygame itself has been downloaded millions of times, and has had millions of visits to its website.

Facts About Pygame

Silliness built in. Pygame is meant to make software things fun. New silliness is added every 3.1415 seconds.

Does not require OpenGL.
With many people having broken OpenGL setups, requiring OpenGL exclusively will cut into your user base significantly. Pygame uses either opengl, directx, windib, X11, linux frame buffer, and many other different backends… including an ASCII art backend! OpenGL is often broken on linux systems, and also on windows systems – which is why professional games use multiple backends.

Multi core CPUs can be used easily.
With dual core CPUs common, and 8 core CPUs cheaply available on desktop systems, making use of multi core CPUs allows you to do more in your game. Selected pygame functions release the dreaded python GIL, which is something you can do from C code.

Uses optimized C, and Assembly code for core functions.
C code is often 10-20 times faster than python code, and assembly code can easily be 100x or more times faster than python code.

Comes with many Operating systems.
Just an apt-get, emerge, pkg_add, or yast install away. No need to mess with installing it outside of your operating systems package manager. Comes with binary installers (and uninstallers) for Windows or MacOS X. Pygame does not require setuptools, or ctypes to install.

Truly portable. Supports Linux (pygame comes with most mainstream linux distributions),
Windows (95,98,me,2000,XP,vista, 64bit windows etc), Windows CE, BeOS, MacOS, Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX. The code contains support for AmigaOS, Dreamcast, Atari, AIX, OSF/Tru64, RISC OS, SymbianOS, and OS/2, but these are not officially supported. You can use it on hand held devices from nokia, game consoles like gp2x, and the One Laptop Per Child (OLPC).

It’s Simple and easy to use.
Kids and adults make games with pygame.ll your functions. This gives you greater control when using other libraries harga samsung galaxy s6, and for different types of programs.

Does not require a GUI to use all functions.
You can use pygame without a monitor – like if you want to use it just to process images, get joystick input, or play sounds.

Fast response to reported bugs.
Some bugs are patched within an hour of being reported. Do a search on our mailing list for BUG… you’ll see for yourself. Sometimes we suck at bug fixes, but mostly we’re pretty good bug fixers. Bug reports are quite rare these days, since a lot of them have been fixed already.

Small amount of code.
It does not have hundreds of thousands of lines of code for things you won’t use anyway. The core is kept simple, and extra things like GUI libraries, and effects are developed separately outside of pygame.

Als je de DEBIAN WHEEZY image gebruikt op de Raspberry dan is PyGame al geïnstalleerd!

Installatie via PIP

Installeer Pygame met het commando:  pip install pygame

Installatie via Source (TAR.GZ)

Krijg je deze foutmelding:

Dan moet er eerst aanvullende bibliotheken geïnstalleerd worden (dependencies), met het commando:

sudo apt-get install mercurial python-dev python-numpy libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsmpeg-dev libsdl1.2-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev


Foutmelding: linux/videodev.h: No such file or directory

Krijg je deze foutmelding:

Dan moet er nog een “video” onderdeel geïnstalleerd worden, met de volgende commando’s:

Ga daarna weer terug om opnieuw pygame te compileren:

Bron: raspberrypi.org


PyGame SDL berichten

Als je een tijdje aan het experimenteren bent met PyGame valt op dat bij het oproepen van bijvoorbeeld een knop status er “debug” lijnen getoond worden…

Ik heb hier een script gevonden om PyGame opnieuw te compileren.

Maak een bestand aan, bijvoorbeeld /usr/src/pygame.sh (evt onder root, en vergeet niet chmod te gebruiken om het bestand uit te kunnen voeren), voeg deze inhoud daar in toe:

Start het script met sudo sh /usr/src/pygame.sh , het script heeft wel even de tijd nodig om pygame opnieuw te maken, als je nu pygame gebruikt heb je geen SDL berichten meer.