XD blog

blog page

games, kivy, pygame, pyglet, pysdl2, python, pythonista


2014-01-01 Frameworks for games in Python

Implementing a simple game in Python is not too difficult if you consider using a module such as pygame. With the multiplicity of devices (computers, laptop, tablets, phones), we may wonder whether or not the same code will work on many of them. So far, I was able to find a couple of modules to implement a game. I mean display graphics, play music or videos, intercept events coming from the mouse or the keyboard:

If the game requires 3D graphics, those extensions will have to associated with pyOpenGL. If my preference goes to pygame mostly because I know it, I would consider pysdl2 because SDL2 now supports Android and iOS (iPad, iPhone). GitHub and Bitbucket are now very popular. You can find examples just by searching the module you want to use: pygame on github, pygame on bitbucket.

However, there exist others solutions. They might need more effort to be used but they seem promising as they could really make deployment on many platform easy. kivy seems very promising. A game implemented with that framework can be deployed on Linux, Windows, Android, iOS. It is also available on Raspberry Pi. kivy allows the programmer to interact the same way with any device. The last one I found is pythonista. It was designed to easily implement Python programs on iOS (iPad), not necessarily games. It only works with Python 2.7 but I hope Python 3.x will be soon supported.

A last solution would be to use a HTML/Javascript solution packaged in a service but maybe, it goes beyond python and the scope of this post.


<-- -->

Xavier Dupré