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

[pygame] Scrolling Tile Engine



I was revamping my scrolling tile engine (ie. code to draw a 2D carpet of
tiles) yesterday and thought that a version of it might be useful to
others. So:
<http://kschnee.xepher.net/code/coral_tile_engine.py>

It's really simple. The demo assumes you're also using the art-loading
module from the "toolset" I put up at
<http://kschnee.xepher.net/code/schnee_tools_demo.zip>, but all it's using
from that is an object containing a dictionary of tiles. The demo will
automatically detect if you haven't got that other module, and slap
together some solid-color tiles so you can see the effect.

The most obvious weakness in this tile module is that it's drawing every
visible tile every frame, which is somewhat less efficient than it'd be to
have a slightly-larger-than-screen-sized surface that gets new tiles drawn
to it only when necessary. I never figured out how to make that trick work
right.