choiceslkp.blogg.se

Hex map maker for android
Hex map maker for android









hex map maker for android

The vertices are numbered somewhat arbitrarily on my part, but we need to refer to vertices in some manner. The orientation will affect how the vertices are calculated. I introduced the concept of orientation so that hexes could be created with the flat side down or a pointy side down. When creating a Hex object, you need to know a few things - the length of a side, the x,y coordinates of the upper vertex, and the orientation of the hex. So, we need a helper method to convert degrees to radians. The Sin and Cos methods in System.Math take arguments in radians, not degrees. Public static double DegreesToRadians( double degrees) Return ConvertToFloat((DegreesToRadians( 30)) * side) Public static float CalculateR( float side) So, how do you find r and h?Ĭopy Code public static float CalculateH( float side) The values for a and b are pretty much irrelevant because you can calculate them from s, r, and h, and you don't really need a and b for any calculations anyway. If you know the length of side s, then you can calculate r and h. After that, you can calculate everything else you need to know. The beauty of the hexagon based map is that you really only need to know one thing: the length of a side of a hexagon. When I use the word hexagon, I really mean regular hexagon, which is a six-sided polygon where all six sides have the same length. The core of my code is based on the geometry of the hexagon. Hexagons are more pleasing to look at, which counts for something, right? The distance from the center of a hexagon to the center of each neighboring hexagon is equal, which eliminates the distortion of calculating diagonal distance in a traditional square based map. The hexagon has six sides, which allows movement in six directions, instead of four. Hexagon based games, whether traditional board games or computer-based, provide more strategic and tactical game-play when compared to simple square based games (like the Checkers game board). This is the first "version" of the hex map, and by no means complete. Drawing shapes with GDI+ and capturing mouse events with Forms is fairly trivial, which would allow me to spend my programming time solving on more important issues (like hexagon geometry!). I wanted to leverage as much functionality as possible from.

hex map maker for android

The goal of my project is to create a modular, reusable hexagon based map that could be used in simple games and ALife applications.











Hex map maker for android