Warning: Pictures only show up in Internet Explorer! - Sorry about that.
The idea
So how can we do this trick? Let's take a look at the new tileset, where the last tile is supposed to be animated:
As you can see all four frames of the animation are on the same tile and next to each other. Now the trick is to simply change the source position when drawing this tile. See the following illustrations:
Tile set |
Index map |
Playfield |
Debug |
|
|
|
|
In the tile set you can see which part of the flower image is currently used as source for drawing the playfield map. And since we're always going to redraw the full screen there's no slowdown caused by the animation. Nifty, huh? This technique also works for people, objects, special effects, whatever you want.
Note again that we're always blitting from the same DC, it's just the SourceX position that changes!
Navigation