Skip to main content
GameDev.net gamedev.net
🔒 Locked

Idea for 2d map format using bitmaps

Started by adam4813 Mar 13, 2007 at 5:13 PM 9 replies 2.1k views
Original Post
adam4813
adam4813
So I have not tested this theory myself, but I would think it would be possible. What I am suggestion is to use a bitmap file to store a 2d map file. This bitmap would contain information such as x and y, which tile to use from a specific tileset, and even height information. You may be asking how would I store that in a bitmap? Well that is simple, use the color values. Each pixel already has a x and y coordinate that part is the simple part. To store in the tile we would use 1 channel such as red. This would allow for 256 tiles. We could expand this to include a second channel such as green that would allow for 65536 possible tiles. To encode the height data we just need to use the third channel in this example blue. Bitmaps also make provisions for a forth channel which could be used for other information such as script ids, or creature ids. Any thoughts or suggestions would be appreciated. I will be posting a rough pseudo code or implementation later.
Cowboy Coder
Cowboy Coder
It's certainly possible. Just not really useful. A bitmap is just a 2D array when it comes down to it. You'd be better off using a proper map editor like Mappy, OpenTUME or Tile Studio.
SunDog
SunDog
What do you gain by using a an image file format to store your map? Just write your map in its own format.
adam4813
adam4813
Well thats what you gain. You don't have to make/find a map editor. Plus there are so many bitmap libraries out there you can easily implement this without having to write your own.
SunDog
SunDog
Quote:
Original post by adam4813
Well thats what you gain. You don't have to make/find a map editor. Plus there are so many bitmap libraries out there you can easily implement this without having to write your own.


But you're editing meanginless values. What does defining the 'red channel to be 128' mean anyway? When you look at the map, you'll see an image that conveys little to no meaning about what is contained on the map. It will probably look like a bunch of noise. And you are limited to 24 or maybe 32 bits per tile, which maybe enough for some applications but not for others. Creating a simple 2D tiled based map editor is not that hard.

adam4813
adam4813
I no i was just pointing out a possible use for something that everyone uses everyday. Random map generation could be easier this way as well with the check if colors are continuous and to be able to easily look at the map in like MSPaint to get a feel for it.
SunDog
SunDog
Its not like I'm going to stop you or anything. I just think its look for a solution to a problem that doesn't exist.
acemuzzy
acemuzzy
I've actually done exactly what you've suggested. I found it kind of easy to start with, but it did have some major shortcomings. Writing your own format is a much better / more logical / more extensible solutions.

Issues I found were:

- I needed a separate file format for e.g. scripting. Having two files for the same map was really ugly, as the information should logically have gone hand in hand.

- The bmp file did kind of show what the map looked like, but not that well.

- It's actually quite fiddly using paint to say 'I want tile 4 at (10,10) on the map. You have to start typing figures in & stuff like that, which isn't as quick as clicking on the tile you want.

And I'm sure there were other problems too. But yes, it is an easy solution to get a simple map going - just not a very long term or extensible one. IMHO.
Positronic Arts [blog]
Iftah
Iftah
I like this idea better as a 16 color bitmap - this can be very useful for a terrain style game (such as civilization/heroes/starcraft).
you can decide (for example) green is grass, blue is sea and brown is mountains.
Then you can edit real fast a large terrain with all the nifty features of a clever editor (such as undo,copy-paste, flood-fill, spray, line,...) you can even have a bonus of downloading an image from the internet and transforming it to 16 color bitmap and have a cool level in the shape of Earth or a dragon or whatever.

For better results you can pass the bitmap to a custom made tool that would add randomized tiles and make smooth transitions.

I really like this idea! If I ever find the strength to create a terrain based game I'll use the bitmap trick.

However, for a platform game (such as Mario brothers, sonic, etc...) I think the you should use a custom made editor, especially if you want the kind of polish you see in the Mario style commercial games.

Iftah.
kelumden
kelumden
Quote:
Original post by adam4813
I no i was just pointing out a possible use for something that everyone uses everyday. Random map generation could be easier this way as well with the check if colors are continuous and to be able to easily look at the map in like MSPaint to get a feel for it.


May be you should give a look at EU3: Paradox uses no less than four (4) bitmaps to encode the map of the game, with additional data files. To see how it is been done, you can download the demo and install it on your computer.

You can also take a look at how AGEOD, with Birth of America, has done it. Here you can also download a demo and take a look at the files installed !
Rand
Rand
This is a very good idea. We've used it in a racing game as a height map. Each pixel is a meter square tile on the map. The benefit that people are missing saying just use an editor, is that the editor here is photoshop. Very powerful. RGB Can be colour of patch, Alpha can be the height.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.