Jump to content
  • Advertisement
Sign in to follow this  
nex7

bitmaps as tile map files

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

im looking to create a file format for my engine and i thought about just using a bitmap...or some other image type... since each pixel would contain 3 layers (r g b) you could easily make a 3 layer map out of it... im just looking for the best way to safe my maps. thanks.

Share this post


Link to post
Share on other sites
Advertisement
A bitmap can be a great way to store a map file but it can also be limmiting. For example, if you were to use each RGB color component as a tile index for a different layer, then you limit yourself to 256 tiles. When working in 2d the number of tiles can greatly exceed 256 quickly just from terrain transitions ( see this great article for some ideas *click*here*click* ).

Ultimately you will eventually want to make your own map file format to suit your own needs. I know it isn't what you want to hear but you will eventually get tired of being tied to someone elses ideas of what is important.

Share this post


Link to post
Share on other sites
Yes, an image would work pretty well, as mentioned above, this limits you to 256 tiles unless you do some post-processing.

It's probably better to have the layers as separate layers in your paint program, then save them out into separate files before you load it in (Photoshop, GIMP formats etc, are not going to be easy to read programmatically)

Plus if you want stuff like terrain transitions, I'd go for having some sort of post-processing which automatically assigns tiles which are adjacent to other specific tiles.

You could also have more than one pixel per tile, for example, 4 px per tile, then your code can automatically place edge / corner tiles on things.

Mark

Share this post


Link to post
Share on other sites
Or you could have one bitmap as one mapfile, and have corresponding bitmaps for extra layers. I won't even start on how to organize all this, but it's just a thought.

Share this post


Link to post
Share on other sites
think im just going to go with writing binary data out....it would have been neat to load up a BMP into pain and just start throwing colors down and make a map. :)

Share this post


Link to post
Share on other sites
Quote:
nex7: think im just going to go with writing binary data out....it would have been neat to load up a BMP into pain and just start throwing colors down and make a map. :)

This is not a half bad idea that I myself have been toying with but I am guessing that it is slightly different than how you are thinking. I was thinking that for making large landscapes (a world map) I could use paint or any other bitmap manipulation program to create a bitmap where green pixels are grass, blue water etc. instead of a randomly generated one that needs lots of touchups or a painstakingly detail oriented one done entirely by hand in a map editor.

Consider this for a second. Using 32x32 tiles on a 640x480 screen you get a 20x15 tilemap per screen. Lets say for arguments sake we have 8 screens wide and 6 screens down (larger than it sounds but still somewhat small). That is 48 screens of hand placing 300 tiles per screen or 14,400 tiles all together. That doesn't even count transitions or details or item placement. In retrospect for a bitmap it would be as simple as filling in a 160x90 pixel image to generate the overall landscape. And then using the article I linked to above it would be a sinch to generate the transitions on the fly when loading the bitmap into your map editor. By that time all you have left to do is place the details and items saving you a lot of work. Hehe, I say that as if it isn't still a lot of work but it really is anyway, however like I was saying, I think this can be a huge time saver.

Share this post


Link to post
Share on other sites
yeah i think it would be really easy to come up with the overall map..then you would still need an editor to really add the detail you wanted.

Share this post


Link to post
Share on other sites
Hi, thought I'd add my comments. :)

I've seen a method where one pixel colour can determine height, wetness and features (buildings, trees, roads, etc).

Basically, you have three channels: Red, Green Blue.

Red = height (256 different heights)
Green = wetness (256 levels of wetness)
Blue = features (256 buildings/trees/roads etc)

After loading your bitmap read off the pixels and with post-calculation you can form your map.

For example:
- Height:
1. Height 0-20 = sea level (then you can have shallow and deep seas)
2. Height 100-200 = "hilly" terrain (obviously assign a hill graphic here)
3. Height 200+ = "mountainous" terrain (you could say over 225 = "perma-snow")

- Wetness:
1. Wetness 0-50 = "dry" or desert conditions.
2. Wetness 50-150 = "normal" conditions.
3. Wetness 150-200 = "wet" conditions (jungle, marsh, whatever).
4. Wetness 200+ = "river" conditions (225+ = large river).

- Features:
This is as simple as assigning an element to each level (256 max). Zero is empty.

In this way, say you have a tile with RGB(152, 185, 204). This means the tile is height 152 (average hilly height) reasonably wet with 185 (rainforest maybe?) with element 204 on the tile which could translate to a gold deposit.

Dale

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!