Hexes [G3D]

Posted by Gamer3D on Aug. 6, 2008, 11:53 a.m.

Many games use a set of square tiles for pathfinding and grid snapping. This grid is not a very good approximation of real life, and can be replaced with a hexagonal grid which may be more visually appealing or help gameplay. The main problem with this is that some easy pathfinding functions in GM, etc. only support square tiles.

With this in mind, and considering making a tactics game using hexagonal tiles, I created a DLL for pathfinding in a hexagonal grid. The basics were done in three days. In another two days, I mananged to improve it to the point where I cannot improve its speed any more without significant effort.

For my convenience, and as an aid to others, I have compiled an extension for GM.

Screenshot:

Links:

Direct Download

GMC Topic (Please comment here)

Data Dump:

  • FPS: 400 - 7700 (worst case scenario - best case scenario) Average: 840.

  • Max grids: 64

  • Max grid size: unlimited x unlimited

  • Tile types: Impassable, costly (cost >= 1).

  • Functions: 21

  • Constants: 2
  • Comments

    OL 16 years, 4 months ago

    I don't see how hexagonal cells have any real benefits, considering that I imagine they'll be slower than using a square grid?

    Gamer3D 16 years, 4 months ago

    No, they are not slower. They are acutally faster (only 6 neighbors instead of 8).

    SixWinged 16 years, 4 months ago

    You can't draw horizontal lines with hexagons though.

    s 16 years, 4 months ago

    Using 8 implies you're using a more hexagon based system. Grid should imply lack of diagonals, because maybe the squares don't want to play octogon for once

    Bryan 16 years, 4 months ago

    Well I don't have a use for it :/

    Gamer3D 16 years, 4 months ago

    I couldn't come up with a better name for hexagons than "grid". Horizontal lines are made by repeated up and down movements.