Skip to content

Generetas and reads hexagon maps with a wonky coordinate system.

License

Notifications You must be signed in to change notification settings

JoonasVaris/hexamap-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hexamap-builder

Generetas and reads hexagon maps made of hexagons with a wonky coordinate system. Each hexa has xy-coordinates and it knows it's neighbours. I made this for DnD purposes.

This does not generate any graphics (yet).

Usage

generateHexagonJSON with wanted final height. It generates an array of Hexagons.

export interface Hexagon {
  id: number;
  x: number;
  y: number;
  neighbourIds: number[];
}

NeighbourIds can be used to determine which Hexagons are valid hexas to move to -- Neat!

image

Coordinate system

Hexagons can't be presented with a single xy-coordinate if you place a hexagon on each coordinate.

Hexagons have six neighbours but each "square" on a standard xy-plane has 8 neighbouring tiles if you count the diagonal ones.

|_|_|_|
|_|H|_|
|_|_|_|

My solution to this is to place each row on its own Y-coordinate

image

And use following notation:

image

This way we end up occupying every other coordinate pair in xy-coordinates as illustrated below

|_|_|H|_|_|
|_|H|_|H|_|
|H|_|H|_|H|
|_|H|_|H|_|
|_|_|H|_|_|

Hexagon (H) and its neighbouring hexagons (N)

|_|_|N|_|_|
|_|N|_|N|_|
|_|_|H|_|_|
|_|N|_|N|_|
|_|_|N|_|_|

Note

This can only generate infomation for these:

 __
/  \
\__/

Not these:

 /\
|  |
 \/

I thought the first looks neater.

About

Generetas and reads hexagon maps with a wonky coordinate system.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published