[...]we will use Java, because a jar file is easier to deploy.This sentence occurs sometimes where I work. In this multi-environment place, a easy way to deploy your software is a fundamental requirement.
Wednesday, 18 November 2015
Wednesday, 3 December 2014
Tuesday, 17 June 2014
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 SituationLet's take a look on Python libraries for gaming.
- 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.
- 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.
- 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.
- 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
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
- a text editor
- a packaging system to deploy my programs, without thinking if my users have Python installed or how to bundle all files
- a easily way to manage animations
- 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 )
- A consequenting animation class whom works with image functions just seen
- Managing projects as entities (something like eclipse)
- 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()
- a way to export such games to mobile platforms
- Reduce final program only to really used modules
- Game configuration as python dictionary
- Save/Load system
ConclusionsThese 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.
Thursday, 17 October 2013
In these days I'm working on Python application for manage some metereological datas. It uses PySide for the GUI and Matplotlib to plot some useful charts. Unluckily, I had some troubles to add this last library. After some work, I found a solution. This post is a brief guide to my little oddity on using PySide and Matplotlib on a Mac OS X environment.
. I resolved using brew again
and installing also pyside-tools to use it in with QT Designer. I did it
staying in virtualenv
Install homebrewFollow homebrew installation instruction from its official site. Basically just type in your terminal
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
Install pythonIt's easy with homebrew. Just type
brew install python
Set PATHSet your Python Path. Write on your .bash_profile
Install virtualenvI know, probably you don't want to do 'cause you want just ONE python. I am with you, but it seems quite hard to do on Mac OS X. So, be patient!
pip install virtualenv
Create a virtualenvI put my virtualenv in the same directory of my project. Probably it's redundant, but it's specific for this project.
cd fooprojectA new directory called py27 will be created. It will contain all python libraries. Now, let's activate our new virtualenv
virtualenv py27 --distribute
virtualenv py27 --distribute
source py27/bin/activateYour shell will become something like this:
(py27)darkstar: fooproject username$
Install PySide and PySide ToolsFor some unclear reasons, pip can't install pyside: it can't find
brew install pyside pyside-tools
Install GFortranNumPy require GFortran. So add it with brew
brew install gfortran
Install matplotlibAlways in virtualenv, I installed matplotlib and numpy
pip install numpy matplotlib
ConclusionProgram and install your packages always from your virtualenv. When you're tired of it, just type
deactivateAnd you'll exit. Good luck: I had many problems with this stuff!