Quote:
I had considered calculating the overlaps and clearing them only once, then clearing the remaining rectangles (to avoid flicker), but this looks pretty expensive.
Would using an auxilliary pixel area get around this problem?
|
Yes. The usual technique to avoid flicker is called "double buffering". This means blitting the bitmap pictures is done in an in-memory copy of the screen, then the entire screen (or for optimizing performance, only the "dirty" rectangles of the screen) is copied at onze to the actual display. When moving a sprite, the rectangle it originally was on is cleared (clean background blitted to it) in the in-memory picture. Then it's blitted on top of the new position, and finally update the display from the in-memory bitmap. SDL for example has a SDL_UpdateRects() function for this. It takes an array of "dirty" rectangles which should be updated to the display. The SDL engine then decides what whether it's more economic to update the entire display, or just a part of it, based on the rectangles that should be updated. When using other programming languages/libs, you may need to code more (or less) of this optimization and "double buffering" yourself.
You don't mention a programming language or libs (SDL?) you want to use, but this is a nice sprite tutorial about SDL w/ Python, which, IMHO can be helps when programming C w/ SDL, or even without SDL:
http://kai.vm.bytemark.co.uk/~piman/...tutorial.shtml
Also, google on "double buffering" (and SDL):
http://www.google.nl/search?hl=nl&q=...tnG=Zoeken&lr=