Reputation: 16720
How many instances of pygame.Surface
is it reasonable to use simultaneously?
More precisely, how costly is it to:
Consequently, how many surfaces can be kept in a list (or any other container), and how many surfaces can be blitted at every frame, with respect for other operations related to the application?
Since this might be too broad, here is a concrete situation. I want to make an animated background, with repeating patterns. I want every element of the pattern to move independently, so I use one surface for each of them.
If I want to display one hundred elements, is it still acceptable to use one surface per element?
Upvotes: 2
Views: 77
Reputation: 1321
I've made games that have had arrays with over ten thousand surfaces in it. It ran just fine. You shouldn't be afraid to use a lot of surfaces, go crazy.
If you've ever seen the game Don't Starve, I was making a game similar to it. I had fifteen different biomes, and I had multiple ground tiles for each biome for variation. That alone pushed it over 100 surfaces. I then had a bunch of different plants, like trees, berry bushes, carnivorous happyplants, etc. There was a large variety of these, and you could have a hundred of them loaded at one time in some locations. Again, each of these had variations. I also had many moving entities, like giant spiders and stuff like that. Some types of entities required over a hundred surfaces, just for all the animations that might occur from their variety of possible actions.
All in all, I probably had a maximum of a thousand surfaces being displayed at one time, and over twenty thousand loaded. The game worked just fine, and it would even run at 60 fps; but not without the extensive use of threads, as expected.
The conclusion: Assume there is no limit, because there may as well not be any.
Upvotes: 2