Tuesday 17 June 2014

What I miss in Python Game Development


As I said before (and I repeated), if I start a new project, I prefer to work with Python, 'cause I like its huge standard library, its portability and its syntax and this is true for every new project I do for work: such as "building netcdf files", "analize meteorological datas", "manage databases". But I had a big problem for a personal project, a long dreamed chimera never really realized: a videogame. I thought to build a simple shooter, something like the old "galaga" or "space impact", using hardware accelerated graphics for great effects, such as particles and flashes. There are many schools of thought on game development under Python: there's PyGame ones, Pyglet, Pandas, ecc. I would like to talk with you about actual game development in python and reflect about my needs

Actual Situation

Let's take a look on Python libraries for gaming.
  1. PyGame is a simple 2D library based on SDL. Good for 2D graphics and integrable with PyOpenGL for 3D. It's still the library with biggest community for Python game development.
  2. Pyglet is a 2D library built upon OpenGL. It's fast, "pythonic" and very pleasant. But it stand still since 2010. No news, few words from devs and, back in 2010, no support on windows 2000. Very bad. I don't ask a lot, just a simple «we are here» from Pyglet developers, some guidelines, a vision for next releases and ports.
  3. Panda3D is simply great. A full featured 3D framework written in C++ and strictly binded to Python to realize 3D games. Great. A bit heavy and maybe a bit much for a 2D engine, but still good.
  4. Cocos2D: yeah! You know Cocos2D as a iOS (and probably its multiplatform C++ 'sister' project, Cocos2D-x), but it started as a Python library based on Pyglet. It's still developed, but being based on Pyglet I am a bit hesitant to suggest it
I found this scenario quite sad: Pygame isn't accelerated and is quite big; Panda is oriented to 3D; Pyglet and Cocos2D could be the best option, but they appear less supported than they're new, shining side-project based on C++/Objective-C.

So, what I miss?

When I started using Lua Löve I feel confortable, even if I don't like Lua very much. With Löve I realized a simple interactive program in few lines of code. Easy and fast, both in writing time and in effective speed. It was also small, 'cause Löve executable is less then a megabyte and it's easy to deploy: just bundle Löve executable and your program zipped and you can give it to every desktop OS.
More frustrating is thinking Python games could do this too. If you try to realize a Visual Novel, with Python you can use Ren'py. Ren'py it's great because it's not just a library, but a full framework where you can manage your projects, add sounds and images, use Ren'py Domain Language to write your visual novel. It cames even with an embedded text-editor (JTextEdit) and offers you many usefull features (take a look here for more info). So, what I really miss for Python game development is a environment, with
  1. a text editor
  2. a packaging system to deploy my programs, without thinking if my users have Python installed or how to bundle all files
  3. a easily way to manage animations
  4. easy to use accelerated 2D graphics. Something like Löve's
    myImage=love.image.newimage('test.png')
    love.graphics.draw(myImage,x, y, r, sx, sy, ox, oy, kx, ky )
    
  5. A consequenting animation class whom works with image functions just seen
  6. Managing projects as entities (something like eclipse)
  7. Have a "main" file such as
    import TheFramework as tf
    
    class Game(tf):
        def __init__(self):
            ...
    
        def Update(self):
            ...
    
        def Render(self):
            ...
    
    x=Game()
    x.Run()
    
  8. a way to export such games to mobile platforms
  9. Reduce final program only to really used modules
  10. Game configuration as python dictionary
  11. Save/Load system

Conclusions

These features are realistic, 'cause Ren'py already does. JMonkeyEngine works in a similiar way using Netbeans as base. If you're looking for a new project, this could be a good idea.

No comments: