Mail Archives: djgpp/1997/11/19/14:04:22
Maybe I have an idea to speed-up blitting in Allegro. If someone has
implemented this already: Please send me a copy.
In a game that I am working on I have to blit a lot of tiles (small
squares that combined in a smart manner look like a map). In a lot of
cases I have to update the contents of a tile. I noticed that the
difference between old tile contents and new tile contents is often
minimal.
As an example, think of a bullet from a tank to a target. The bullet is
very small in relation to a tile but to draw a nice animated movement a
have to blit the tile several times (something like):
L01 BLIT(tile_gfx,tile_buf);
L02 SPRITE_BLIT(sprite_gfx,tile_buf);
L03 ...
L04 BLIT(tile_buf,screen);
I think that it may be faster (in line L04) to first compare the
new_tile contents to the old_tile contents. This would look like this:
First rebuild the old tile (or store it somewhere)...
L01 BLIT(tile_gfx,old_tile_buf);
L02 SPRITE_BLIT(old_sprite_gfx,old_tile_buf);
L03 ...
Second build the new tile
L04 BLIT(tile_gfx,new_tile_buf);
L05 SPRITE_BLIT(new_sprite_gfx,new_tile_buf);
L06 ...
result contains only different pixels->rest is transparant.
L07 COMPARE(new_tile_buf,old_tile_buf,result_tile_buf);
L08 SPRITE_BLIT(result_tile_buf,screen);
What is your opinion?
- Raw text -