[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Big Tile Maps



Simon Wittber wrote:
Hello Chaps.

I'm attempting to create a data structure for efficiently storing
large tilemaps, and objects within the map. The map is a 2d overhead
view of a terrain, which is scrolled when the mouse cursor is near the
edge of the game window.

I've tried using a quadtree, but this is not very efficient when
working with moving objects, which move from tile to tile.

I've also experiemented with a grid type system, and a moving window
into the grid.

I'm not satisifed with any of my solutions, and am wondering what
other people use for this sort of thing.

Has anyone got some pointers, or some code I can look at?


I'm getting 70-100 FPS by drawing a 50x50 to 100x100 map of 64x64 tiles once to a really big surface, then blitting a screen's worth of it every frame using a moving rectangle. This gives me fast, smooth scrolling. Want to see the code?

For a huge terrain it might be better to load a "zone" of the game world where the player is, and the eight surrounding zones, in preparation for smoothly scrolling bits of them onto the screen. The memory requirements would be big, but you could then let the player walk all the way across the world without going to a separate Loading screen, a la "Morrowind."

Kris