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

Interactive Map (technique)?

Started by DpakoH Jun 20, 2010 at 2:05 PM 4 replies 1.1k views
Original Post
DpakoH
DpakoH
hi all,

look at this map:
example
in this example USA territory is colored in Red, but if USA conquers Canada(just for example) then Canada should be colored in Red too. How is this done in a game? What technique is used for manipulating images and changing them? Any help will be greatly appreciated!

Have a nice day!

PS: i hope i made my question clear :)
MarkS
MarkS
You could do a flood fill, but that will be problematic as some of the countries are so small that their borders touch on the map, leaving slivers of pixels and in the case of Canada, there are dozens of islands to include.

The best way, but most labor intensive would be to define each country as a list of triangulated polygons and fill the polygons as needed. Another would be to keep two copies of the map in memory. In one, fill each country with a different color. When a country is conquered, scan through that map, pixel by pixel, and when the correct country color is matched, fill that pixel in the other map with your color of choice and display the second map. If the maps are small enough, you can do this with not much of a performance hit.
No, I am not a professional programmer. I'm just a hobbyist having fun...
rubicondev
rubicondev
The easiest way is to use a palettised image and give each country a unique colour. Then you just change the right palette entry when a country changes ownership.

If you have an RGBA image you can still do this, just start with unique colours again, but do a per-pixel RGBA match to find a particular country-coloured pixel and then overwrite it with the new one.
------------------------------Great Little War Game
DpakoH
DpakoH
Thanks for your replies. But what if countries are divided in many regions. And if you conquer for example just one out of ten enemy regions, then the map has to be update and draw the conquered region with your country's color. In this case I can not scan the whole image for a specific color and redraw it in another color (cuz it is just a part of the country that is conquered). Any other ideas?

Again, thanks for the answers, I am still google-ing and searching for information about my issue :)
iliak
iliak
Just make a white image for each country, then draw this image with the desired color. Let me be more clear.

Have a full picture of the world with only outlines of the countries (states are in white). Then have a picture of each country in white (no borders, or black borders). Then when you draw the country set the desired color of the country. In OpenGL when you display a texture with a color different of white, the the texture is tinted.

Hope to be clear (not sure...).
- Iliak -
[ ArcEngine: An open source .Net gaming framework ]
[ Dungeon Eye: An open source remake of Eye of the Beholder II ]
Krohm
Krohm
Or maybe work on real geometry instead of pixels, it would have some advantages, and with some degenerate polys and some shader magic you could have it drawn in a single batch.

By the way, am I the only one finding "strange" that Iran was granted ability to build a nuclear reactor and then, only a few months later, we find it marked high-risk?
Previously "Krohm"

Topic Locked

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

Sign in to reply to this topic.