Jump to content
  • Advertisement
Sign in to follow this  

Texture representation

This topic is 4891 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
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
Sign in to follow this  

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!