rik-cross / pygamepal

A library of classes and helper functions to support game development in Pygame.
MIT License
25 stars 2 forks source link

Camera zoom affects performance #15

Closed rik-cross closed 2 months ago

rik-cross commented 6 months ago

Zooming in slows down the game, most likely due to drawing larger images. To see an example, run fullExample.py and walk towards the trees.

rik-cross commented 6 months ago

The main issue here is that the standard-sized source surface when zoomed in becomes quite large.

I've added a worldSize parameter to a scene, which can be set smaller if required.

A good fix for the future would be to get the viewable subsurface of the source surface, although that might not solve the problem (images would still be drawn to the surface ahead of getting the subsurface).

mauricego commented 5 months ago

Hi, did you find any solution? I have basically the same problem for my game...

rik-cross commented 5 months ago

In my case, the slowness was due to drawing to a surface the size of the screen, which was zoomed in quite a lot. The only solution I have is to use a smaller surface. I also know that you can use .convert_alpha() on textures to speed up the drawing.

rik-cross commented 2 months ago

Closing this, as it works well with reasonably-sized target surfaces.