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!
hi,
ReplyDeleteif you're on windows pygame now uses the windib (GDI) driver instead of the directx one by default.
We had to do this for compatibility with, funnily enough, vista :)
You can do the following, and it should become similar to before...
import os
os.environ['SDL_VIDEO_DRIVER'] = 'directx'
On some computers though the windib (GDI) driver is faster, and your game will also be more compatible with windib.
We're trying to figure out a fix for the funny sound, and I think we're getting close to figuring out the problem.
For some things the blit functions are faster in pygame 1.8 because they use mmx assembly.
To fade to black for example you can now do this with the new blenders (available in blit, and fill methods) ...
screen.fill((2,2,2), None, BLEND_SUB)
Put that in a loop and it will subtract 2 from the r,g,b channels until all the colors are (0,0,0). Maybe you could use one of the new blend modes for your fades?
cheers,
Thanks for the DirectX driver tip, it works a lot better now :)
ReplyDeleteThe sound problem is quite strange, it doesn't seem to be related to the game running slowly at all - it pops and crackles even on a completely empty file. I did notice in the release notes something was mentioned about the sound module default settings being modified so as to crackle less on some computers, and I have played with the settings a bit - I actually got it to play sounds perfectly without any crackliness, but unfortunately I did it by drastically reducing the sample rate which made it sound almost as bad. Good to hear you're getting close to finding out the problem though :)
I think some nice people have found and fixed the sound crackling...
ReplyDeleteYou can try it out with the development builds of pygame here:
http://thorbrian.com/pygame/builds.php
I'd be interested to know if it fixes the problem for you?
Hi, do you know where can I find a tutorial for pygame.
ReplyDelete