Fast bitmap loading

Started by
12 comments, last by Usako 22 years, 7 months ago
^_^

The problem is not the drawing itself (I have the tile blitting engine and all the stuff like collision detection running and running fast here).

I only am wondering on how to load and draw hundreds of always changing little pictures (a few hundred heads, a few body''s, lotse different swords etc.). In that graalonline game you can have like (I think) 40 different people on the screen at once, all with different heads/swords/bodies etc. Now I want to know a good way to do that without getting slow (not the drawing of the people but the storing of all those images in memory).

...damn, I''m not very clear I think ^^
Advertisement
Either create a surface for every head body sword etc... this will eat up tons of video mem because of alignement issues and will be a horrible beast to maintain. OR go with the tilebased approach, If you already have the tileengine running then this shouldnt be a big step, just picture the characters as beeing multilayerd tiles and draw them that way, if you have 40 ppl onscreen and they all need shoes body and head that will amount to about the same as 120 tiles your engine should be able to handle that without slowing down.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
Also it could be an idea to use some sort of smart container so that you don''t load every head there is, when only a couple are needed. The way you can do this is to have a gfx manager (prolly a class) using some kind of hashtable and you tell it that you want the number for head166.gif and it gives it to you or loads it assigns a number to it and gives it to you, when you want to draw you just either tell it to draw head number X somewhere on the screen, or you have it return a pointer to a surface containing the gfx and a rect to blit from, much as you would implement a tileset class, and Im guessing you already have one of this in one form or another
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
I think I know what you''re asking... You want to know how to shift bitmaps into and out of memory as you need them, because loading all of the bitmaps at once would use lots of memory. I was thinking about a couple ways of doing this recently, but the problem with this approach, I think, is that constantly thrashing bitmaps will really slow the game down. So, is there any way do this and still have a game at a playable speed? I''ve been reading about bitmap managers which pre-load a certain number of bitmaps, and take a reference count of each bitmap on the screen each frame to see which bitmaps are used most often. The ones that are displayed least often get flushed and replaced with ones that are used most often so that the video-memory always holds a the most-used bitmaps and the system memory always holds the least-used bitmaps. Blits on the average will be faster because more blits are being done per frame from the video memory than from system memory. I don''t know if that helps or not, but it''s something to think about.

Paradigm Shift 2000
"I am Locutus of Borg. Resistance is Futile." -- Locutus of Borg

This topic is closed to new replies.

Advertisement