0

I'm designing a game in pygame that you can download here: https://github.com/hailfire006/games unfortunately, when you fly the ship near the space station, the framerate drops from a nice 30-40 to 16-20. I believe this is due to my blitting sprites onto the screen every frame, and I have been told that there is a way to only redraw parts of the screen that need redrawing, but no one ever explains how to do this.

Someone please help, I'm beginning to worry that I should abandon hope of ever making a good game in python, and that I'll have to learn an entirely new language just to deal with framerate...

p.s. any other way you know how to raise the fps would be welcome also

user3150635
  • 509
  • 2
  • 9
  • 26
  • Maybe a better question on http://gamedev.stackexchange.com/ ? Even there, you'll want to be a bit more specific. – Will Mar 06 '16 at 04:14
  • A good idea for almost any performance question like this is to profile the code. It will tell you what bits are taking the most time, and therefore the places you can make the largest improvements. – Blckknght Mar 06 '16 at 04:35
  • any tips on where to find a good profiler for python? – user3150635 Mar 06 '16 at 04:44
  • The only things you need to redraw are the things that moved. To "erase", you need to blit your background *only* where the thing that moved *was*. So after you blit to the screen, and update, immediately blit the background back, then you can repeat this. I didn't post as answer because I'm not sure this is the actual correct way to do this. The way I handle it in my game is jjust redrawing the background every frame, since the background moves in my scenario. – David Jay Brady Mar 06 '16 at 08:35

0 Answers0