![]() ![]() Support the 0,0 hex being located on the screen anywhere.The main article only supports equilateral hexes. Support stretched or squashed hexes, which are common with pixel graphics.The main article only covers y-axis pointing down. Support y-axis pointing down (common in 2d libraries) as well as y-axis pointing up (common in 3d libraries).The main article doesn’t cover some of the additional features I want: To draw hexes on the screen, I need a way to convert hex coordinates into screen space.A 2d array can be used but it’s not always straightforward, so I’ll create a Map class for this. A grid map will likely need additional storage for terrain, objects, units, etc.For offset coordinates, I’ll make a separate data structure Offset. Cube and axial are basically the same so I’m not going to bother implementing a separate axial system, and I’ll reuse Hex. For some games I want to show coordinates to the player, and those will probably not be cube, but instead axial or offset, so I’ll need a data structure for the player-visible coordinate system, as well as functions for converting back and forth.Since most of the algorithms work with cube coordinates, I’ll need a data structure for cube coordinates, along with algorithms that work with them.The first thing to think about is what the core concepts will be. Now let’s write a library to handle hex grids. The main page covers the theory for hex grid algorithms and math. The data structures and functions here implement the math and algorithms described on that page. Note: this article is a companion guide to my guide to hex grids.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |