I am trying to use a map of the real world, but I need to have a way to break it down by countries and regions. Ideally down to a province level. I figure that I'd need to be able to define polygonal regions on the image and export the points that represent the bounding polygon, so that I could check for clicks inside, and do other things with it. I'm having a hard time finding a tool that will let me do this, that is, load in an arbitrary image and start defining polygons on it to be exported. Or am I going about this the hard way? Using XNA/Monogame currently if that matters in your answer. Thanks


1 Answer 1


You could use polygons, or you could do a quick and dirty hack and just get a political map like this one: this one
(source: freeusandworldmaps.com)
. Then, pick a unique color for each country and flood fill it in paint or photoshop. Then, you have a simple file that just has the mapping of countries/provinces to particular colors. Just something like this:

# Country,      #Unique RGB color
"Afghanistan",     (0, 0, 0)
"Albania",         (1, 0, 0)
"United Kingdom",  (255, 0, 0)
"United States",   (0, 1, 0)
"Kingdom of Zzyx", (0, 255, 0)
"ZZZland",         (0, 0, 1)

Then, when the player clicks on the map, just sample the color image, and find the color associated with it. Of course, this will be limited to the resolution of the selection image. This also gives you control over the political boundaries you want to select. For instance, if you just want to select continents, you could use an image like this: image
(source: zonu.com)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .