Archived

This topic is now archived and is closed to further replies.

Drawing a map (from a matrix)

This topic is 5315 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I have a matrix which represent my map: int map[20][20]; I do 2 for() to draw the whole map. if 0 > im1.bmp if 1 > im2.bmp... how do I have to proceed: do I have to load each image im1.bmp, im2.bmp... before drawing even if some bitmaps are useless on this part of the map that will be shown on the screen? Or do I have to load it each time I need it... hm I don''t think so, but loading all in mem before using it is not too big for the mem? my images are 32x32 images... thanks ANT

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You''re making it obscure for any reader out there, but to answer to your last question, nope, it''s not too big for the memory in any case. (your question is far too vague).

Share this post


Link to post
Share on other sites
You could always loop through the matrix and check so if you don''t have a certain bitmap code int the array you don''t load it into memory.

I''m not sure what you mean, but you don''t have to reload a bitmap to a surface/buffer between blitting calls if that is what you mean.

Share this post


Link to post
Share on other sites
I have a matrix

000...0012021110
00111...21451000
...

0: image1.bmp
2: image2.bmp
3: image3.bmp

how do I display my map: do I have to load before scanning the matrix item by item all the bmps? or do I have to load the bmp each time I have its corresponding number?

Share this post


Link to post
Share on other sites
load them all (or at least the ones you use) beforehand, so you only have to look them up when drawing (otherwise it will be very slow)...

it would be better overall if you put all the tiles into one bitmap though, and just blit the appropriate piece each time.

Share this post


Link to post
Share on other sites
i myself just finished creating a tile display. what you do is you have a structure for your tiles, with coordinats on the map and coordinates on your chipset (all of your images are in one file). when looping through the file and getting the information, you obtain the x and y coordinate of the image you are using in the chip set (much like it would be on your map), and then you get the souce rectangle (or square in this case) by multiplying the x and y chip coordinates by the cell width and height, this will get you the image. ou only have to load one image, once.

----------------------
i code therefore i am.

Aero DX - Coming to a bored Monitor near you!

Share this post


Link to post
Share on other sites