That is hardly as convenient...then i have to handle the images one by one.I have a map composed of tiles. I want the map to be a bitmap, and to draw the tiles over it. That way, when I move the camera, I don't have to redraw all the tiles but rather draw a different segment of the map. It will make the game run faster.

Edgar Reynaldo

Umm... It does the exact same thing, only using sprites with zero alpha instead of magic pink.....

jim109109

But can it draw on another bitmap rather than the actual display? :O*Really the problem with drawing on display is that I wanna store the resulting image in a variable for further use, manipulation, etc, for example drawing a sub bitmap

I have a map composed of tiles. I want the map to be a bitmap, and to draw the tiles over it. That way, when I move the camera, I don't have to redraw all the tiles but rather draw a different segment of the map. It will make the game run faster.

I would not be so sure of that, especially if the map is large. By all means try it though.

Thomas Fjellstrom

Drawing to bitmaps and "double buffering" like that is likely to be slower than just drawing directly to the screen. You can't think of allegro 5 behaving anything like allegro 4 performance wise. They are completely different. Essentially, the most compatible and fastest way to draw in A5 is to just dump everything directly to the screen, optionally skipping stuff that just gets overdrawn later (though that may not matter much with a simple 2d game).

One tip for a5 is to put all of your tiles and sprites into a single bitmap (aka: an atlas) and then wrap all of the drawing of the items in that atlas in al_hold_bitmap_drawing calls. It's an implementation detail, but a fairly important one. This way allegro won't needlessly change the texture state, and it'll hold all of the drawing till you unhold the drawing, so it gets transferred in one large blob. It can mean a significant speed up for things like tile maps.

Note, some systems may not support drawing to textures, or if they do, it'll be quite slow. Something to watch out for.

jim109109

I will probably try both methods and let you know which is faster.

Here's how I would go about drawing tile by tile (correct me if wrong):- Have a tileset loaded in memory- Use create_sub_bitmap to load each tile [once on map load]- Redraw the tiles where needed in viewable screen with each movement of character

or- Create a new sub_bitmap per tile at each change in camera with al_hold_bitmap_drawing to not duplicate load

*The way my camera will be setup, every movement will alter the camera and the tiles will have to be redrawn.

====================================

UPDATE:Exciting days are here! The test results are in!

Both draw methods have an execution time of 0.001 seconds! Therefore, any of the two are viable.

However, drawing the whole map beforehand uses up MORE MEMORY and has an initial load of 0.019 seconds [on map load]!

Drawing tiles directly on screen is ALSO independent of map size. For these reasons, I will use that method!

Thank you for the valuable help, my questions have hereby been FULLY ANSWERED TO MY SATISFACTION!