Jump to content
  • Advertisement
Sign in to follow this  
AnthonyVelazquez

Allegro Tiles

This topic is 2771 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

I have a 128 x 8656 Tile Set, that I want to use for my game.
I know how to render a map with an array, but I always split the images between files for example:

Tile[0] = load_bitmap("Whatever.bmp",NULL);
Tile[1] = load_bitmap("Whatever.bmp",NULL);
Tile[2] = load_bitmap("Whatever.bmp",NULL);
Tile[3] = load_bitmap("Whatever.bmp",NULL);
Tile[4] = load_bitmap("Whatever.bmp",NULL);



And so on and so forth, but how can I do the same thing with only one bmp file?

Each image is 16 x 16 but I dont know how to do it exactly...

Temp_map[10][10] = {
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 1, 1, 2, 3, 3, 3, 3, 4, 1, 1 },
{ 1, 1, 5, 1, 5, 1, 5, 1, 1, 1 },
{ 1, 5, 1, 5, 1, 5, 1, 5, 1, 1 },
{ 1, 1, 2, 3, 3, 3, 3, 4, 1, 1 },
{ 1, 5, 1, 5, 1, 5, 1, 5, 1, 1 },
{ 1, 1, 5, 1, 5, 1, 5, 1, 1, 1 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};



Would I be able to do that with an array like this or would I need to do something different?

I am using the Mappy Tile Map Editor to make the array and then I use allegro in my program, but its going to get a lot harder because of all the bmp's I will have to list.

Any help?

Share this post


Link to post
Share on other sites
Advertisement
[quote name='aanthonyz1']
And so on and so forth, but how can I do the same thing with only one bmp file?
[/quote]

You can use a map or vector for your resources and then store the referenced BITMAP* in your array.


vector<BITMAP*> images;
images.push_back(load_bitmap("image1.bmp" , NULL));
images.push_back(load_bitmap("image2.bmp" , NULL));
images.push_back(load_bitmap("image3.bmp" , NULL));
images.push_back(load_bitmap("image4.bmp" , NULL));
images.push_back(load_bitmap("image5.bmp" , NULL));

// load your Mappy map

// create a map of Allegro BITMAP*
BITMAP** tilemap = new BITMAP*[width*height];
for (int y = 0 ; y < height ; ++y) {
for (int x = 0 ; x < width ; ++x) {
tilemap[y*width + x] = images[mappy_map.GetTileInteger(x,y)]
}
}

// loop through images and call destroy_bitmap



If you meant how do you do the same thing with a tileset made of a single image, then you want to use sub bitmaps - see create_sub_bitmap. Or you can create an array of BITMAP* and then blit each tile into a BITMAP*. Either way, you should only have to load each image once.

Share this post


Link to post
Share on other sites
[font=verdana, helvetica, sans-serif][size=2]Basically, I have one bmp file that has all my tiles inside.I would have to blit each 16x16 tile into a different Tile array number?


[/font]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!