Selecting areas on an image?

We are doing a risk-style game where we need to select a country on a map. What is the best way to do this? Due to the non-rectangular shape of the countries, we aren't sure on how to do this.
[200 byte] By [Blazeixa] at [2007-10-2 3:15:07]
# 1
Check clicks against polygons http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Polygon.html
tjacobs01a at 2007-7-15 21:42:19 > top of Java-index,Other Topics,Java Game Development...
# 2

I am presuming you are using a GIF/JPEG as the map, rather than creating the world using a graphics primitives like Polygon, so one idea of the top of my head might be:

(1) Create a "masked" 2 colour version of the map (i.e black and white - black representing sea, white oceans etc). This can be done easily in most graphics packages - Paint Shop Pro, GIMP etc

(2) Create a new image using 32 colours, copy/paste in the 2 colour black&white image and then "colour in" the segments of the map representing each country area using a different colour.

(3) In your game, load in a copy of this map into memory (i.e. not for display), and then check what the colour is on our reference map at the same Point the mouse is on the actual "displayed to player" map. If it is say for example, "Red" - R255, G0, B0, you could then display a "highlighted" image of the country in question.

Hope this provides you with some food for thought.

Cheers,

Pete.

Red27a at 2007-7-15 21:42:19 > top of Java-index,Other Topics,Java Game Development...
# 3
Thanks for all your help. I think that polygon thing would be the easiest. Thanks!
Blazeixa at 2007-7-15 21:42:19 > top of Java-index,Other Topics,Java Game Development...