Any way to speed up Python and Pygame?

前端 未结 6 1496
故里飘歌
故里飘歌 2020-12-28 08:37

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 com

6条回答
  •  余生分开走
    2020-12-28 09:07

    When using images it is important to convert them with the convert()-function of the image. I have read that convert() disables alpha which is normally quite slow. I also had speed problems until I used a colour depth of 16 bit and the convert function for my images. Now my FPS are around 150 even if I blit a big image to the screen.

    image = image.convert()#video system has to be initialed
    

    Also rotations and scaling takes a lot of time to calculate. A big, transformed image can be saved in another image if it is immutable.

    So the idea is to calculate once and reuse the outcome multiple times.

提交回复
热议问题