Wednesday 2 April 2008

Pygame upgrade (well, something-grade...)

So I recently upgraded PyGame to the new version 1.8.0 release... GARGANTUAN mistake. As it happens, 1.8.0 is to PyGame as Vista is to Windows. While Slipslide 2 previously ran like a cat wearing a rocket booster, it could now be compared with an arthritic snail wearing chainmail armour. The initial fade-in took a full 10 seconds (compared to less than 1), and the music was so crackly it was like listening to white noise. The levels were even worse; the character was seemingly incapable of moving at any more than three pixels per hour and the pause menu window lagged several frames behind the mouse's movement.

The cause for this appeared to be that the new PyGame release's blit() method (used for copying images onto the screen) is far slower than before. Thankfully, there is a solution. I only had to make it convert all the images into a pixel format that PyGame prefers, and now blits are much faster. It seems this release is much less tolerant of unconverted images, and will run incredibly slowly when given images that worked perfectly in previous versions.

I'm happy to say that it's almost completely fixed now; the music still pops occasionally but I'm gradually eliminating that. As well as converting all the images, I've also been optimising redraw methods and minimising the number of times it has to update objects. With luck, it'll soon be usable again!