The problem is that i’m using hex for the cases, so no way using a basic grid.
My solution is :
- An ugly .gif with different colors on each cases.
- A nice .jpg image I put in front of the other one
I get the coord of each case by simply picking the the Blue and Red RGB value on the .gif => gives me X and Y position
it gives something like this :
public void paint( Graphics g ) {
g.drawImage(land.getLandImageMap(), 10 , 20, this ); //the ugly gif
g.drawImage(land.getLandImage(), 10 , 20, this ); //the pretty jpg
}
public void mousePressed( MouseEvent e ) {
try
{
int pcolor = land.getLandImageMap().getRGB(e.getX()-10,e.getY()-20);
Color c = new Color(pcolor);
System.out.println("("+(c.getRed())+";"+(c.getBlue())+")");
}
catch(Exception ex)
{
System.out.println("out of image bounds");
}
}
the color of the cases on the .gif looks the same but they are not (+1bleu for x and +1red for y)
http://img266.imageshack.us/img266/2646/ttoqm3.jpg