Sign in to follow this  

Texture representation

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

My game is tilebased, Ive got a vector which holds the data for all the tiles. std::vector <char> tile; // holds the data for all the tiles Im looking for a good system to represent the textures that is to be drawn at the tiles. One way I thought of is to make a .txt file in the image folder with the same name as the image. The file contains only one char, and thats the one that represents that texture in the vector. But how do I store it that way? I store the bitmaps in a std::map. std::map <std::string, SDL_Surface*> Bmp; // holds all the texture There I get the textures by using the filename for the texture. I just dont know how to get it all together, any ideas?

Share this post


Link to post
Share on other sites
My first map system was really simple.

The format went like this

4 4
2
images/sky.bmp
images/ground.bmp
0 0 0 0
0 0 0 0
0 1 0 0
1 1 1 1


The first two numbers were the width and height of the map in tiles.
The second line was the number of textures used in the map.
The next few lines list the names of the texture files.
The rest is the map data.

I loaded the textures into a vector in the order they were listed in the file so that the texture at texvector[0] was sky.bmp and texvector[1] was ground.bmp

The numbers in the map just correspond to that.

It was simple and it worked for me.

Share this post


Link to post
Share on other sites

This topic is 4546 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this