Pygame Project Based on Ludum Dare 23 Entry


5 posts
by tcstyle » Mon Jul 02, 2012 8:03 pm
My first project on the Pi will be testing my Ludum Dare entries made with python and pygame to run on the Raspberry Pi.
After installing the missing sound module in squeezy the first test with my game Bottlecolonies went quite well. Unfortunately the performance of the few animated stuff is rather poor. So I'll do some experiments/profiling to figure out what's causing this and post updates about the results here.
Image
If you want to try it out, download this archive, unzip and type
python Bottlecolonies.py

after changing your command line directory to the regarding folder.
Posts: 10
Joined: Mon Jul 02, 2012 6:47 pm
Location: Hannover, Germany
by dualtagh » Fri Jul 06, 2012 1:57 pm
Cool, good idea.
I was planning on developing a few light weight pygames myself.
One thing I would like to do is to make a Steam-like game manager for pygames on the Pi.
Posts: 16
Joined: Fri Jul 06, 2012 7:32 am
by tcstyle » Sat Jul 07, 2012 3:58 pm
One thing I would like to do is to make a Steam-like game manager for pygames on the Pi.

That sounds like a great but pretty challenging idea. Have you thoght about technical issues, like where the games are hosted, yet? Nevertheless would be pretty cool to have.

Regarding my game, after profiling I found some bottlenecks that take a lot cpu power. Mainly how the bitmap font has been blitted and how the gui is updated every loop in a rather stupid way. I'll try to solve that for the next update of the game.
It's quite a great experience to look that deeply at your code. And also quite challenging with a code mainly made in less than 48 hours. :roll:
Posts: 10
Joined: Mon Jul 02, 2012 6:47 pm
Location: Hannover, Germany
by tcstyle » Sun Jul 08, 2012 7:26 pm
After first profiling and struggling with code optimization I got some interesting results.
First I was able to speed up the blitting of my number font to a third of the initial time per call. This was possible by removing an unnecessary copy of the surface in every call.This leads to the second insight, which is: calling the python copy/deepcopy methods is really cpu stressing. Pygame seems to do this a lot within sprites and sprite groups. I have to take a deeper look at that.
And third, I tried out to start my game in fullscreen with hardware acceleration and double buffer, which works but doesn't improve the speed but rather slows every call down a tad.
So it looks like there is still some potential to improve the game code-wise and make it run faster. I will keep on trying.
Posts: 10
Joined: Mon Jul 02, 2012 6:47 pm
Location: Hannover, Germany
by dualtagh » Mon Jul 09, 2012 7:50 am
tcstyle wrote:
Have you thoght about technical issues, like where the games are hosted, yet?


No not at all, It is just something I'd like to do eventually! :)

Good work on the profiling, You should keep a list of optimization tricks you find for Pygame pi users
Posts: 16
Joined: Fri Jul 06, 2012 7:32 am