Calculating grid coordinates for rotated map

Hi,

First off, it seems that your grid numbering goes the wrong way.

Image VASSAL
2025 1827
2126 1828
2024 1927
2125 2028

However, that’s not the full story. In the top part of your image, you have a grid where the last coordinate is vertical and ascending from top to bottom - that’s pretty standard.

The first coordinate, however, is diagonal and ascending from top-left corner to the bottom right-corner. Other games, most notably older Avalon Hill games such as Afrika Korps, Blitzkrieg, D-Day, etc. uses a similar grid.

There’s really no way that VASSAL can deal with that in any sensible manner.

What you need is a custom grid numbering. I have implemented that in ObliqueHexGridNumbering.java. You need to

  • Optionally, open up ObliqueHexGridNumbering.java in a text editor and change the namespace to something different than dd - e.g., foo

    // package dd;
    package foo;
    
  • Compile the Java code into a .class file. Make sure you have the Java Development Kit installed. Suppose you have VASSAL installed in `/opt/vassal’, then do in a terminal

    > javac -cp /opt/vassal/lib/Vengine.jar ObliqueHexGridNumbering.java
    
    • For less sensible OSs you may have VASSAL installed in C:\Program Files\VASSAL, then do

      > javac -cp "C:\Program Files\VASSAL\lib\Vengine.jar" ObliqueHexGridNumbering.java
      
  • Put the ObliqueHexGridNumbering.class into your module (Add custom class). Make sure that the file goes into a sub-directory that has the same name as the package line above - e.g., dd or foo.

  • In the VASSAL editor, remove your current grid numbering from the problematic zone, and add a ObliqueHexGridNumbering component instead. Adjust the settings on the component to suit your needs.

@VASSAL core: Perhaps this component could make it into the official code base? ObliqueHexGridNumbering is rather small and main override HexGridNumbering.getRow.

Yours,
Christian

1 Like