I am writing a simple top down RPG in Pygame, and I have found that it is quite slow…. Although I am not expecting python or pygame to match the FPS of games made with compiled languages like C/C++ or even Byte Compiled ones like Java, but still the current FPS of pygame is like 15. I tried rendering 16-color Bitmaps instead of PNGs or 24 Bitmaps, which slightly boosted the speed, then in desperation, I switched everything to black and white monochrome bitmaps and that made the FPS go to 35. But not more. Now according to most game development books I have read, for a user to be completely satisfied with game graphics, the FPS of a 2d game should at least be 40, so is there ANY way of boosting the speed of pygame?
Share
Use Psyco, for python2:
Also, enable doublebuffering. For example:
You could also turn off alpha if you don’t need it:
Instead of flipping the entire screen every time, keep track of the changed areas and only update those. For example, something roughly like this (main loop):
Most (all?) drawing functions return a rect.
You can also set only some allowed events, for more speedy event handling:
Also, I would not bother with creating a buffer manually and would not use the HWACCEL flag, as I’ve experienced problems with it on some setups.
Using this, I’ve achieved reasonably good FPS and smoothness for a small 2d-platformer.