[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Big Scrolling Surfaces
My project now involves an "infinite treadmill" of map zones, so that
the player can walk forever in any direction. The game loads 25x25 areas
of 64x64-pixel tiles (ie. 1600x1600 pixels), and loads _nine_ of these
areas at a time so that the next zone is always visible beyond a zone
boundary. (That is, the eight zones around the current one are visible.)
This whole 3x3-zone region is drawn on a single Pygame surface.
But this is a memory hog of a graphics system! 1600x1600x9 = 23,040,000,
times 3 bytes per pixel should = 69,120,000 bytes for the surface!
Windows' Task Manager reports "only" about 109,000 KB memory usage for
my whole program, which uses not only this gigantic surface, but the
main blitting surface (800x600) and various other loaded graphics etc.
Am I nuts for using such a big surface, or should I expect it given what
I'm trying to do? I eventually want to have an "overlay" layer for
objects that the player can walk behind (like the tops of trees); am I
going to need another huge surface, or should I handle them like
sprites, blitting them directly to the drawing surface even though most
will fall outside it? Would it make sense to trim the 3x3-zone area to
more like half-a-zone in each direction, including only the areas the
player can see without leaving the zone -- even though it'll then be
less practical to save parts of the drawn image on loading a new zone?
Kris