Further Fun With Hexes

The screenshot above might not look all that different from the one I posted last month, but a fair amount of work went into getting the game to this stage. Originally I had hard-coded the area of hexes that were covered by a ordinance weapon’s firing arc and range, which worked fine for calculating where the player could target but was useless for determining AI attacks, which might have different ranges. So I went in and rebuilt the function that would return a list of hexes that could be targeted by a weapon on a given unit.

This ended up being much more complicated than I had anticipated, and revealed some serious issues with both my Field of View and Line of Sight calculations, mainly relating to converting hex locations to orthographic grid points.. Long story short, I had to add an extra function to plot the map hexes on an ideal orthographic grid to calculate the angle between any two map hexes. Once this was done, I could accurately check all hexes within weapon range to see if they fell within the weapon covered arc.

This is one of those cases where a system works well enough, until it doesn’t. Now the calculations for line of sight are much more accurate and can be used to determine visibility between any two hexes on the map. I can also display the covered arc of that player tank’s main gun as shown above, although I will likely increase the width of the arc since as you can see, it leaves a blind spot at the edge of the map where no possible turret facing can bring the target hex under the firing arc.

I also cleaned up the Order of Battle display in the bottom left of the screen, displaying enemy units in red and friendlies in White. Infantry units are also now part of the game (eg. the unit at the bottom of the map above), although transports for them (mainly unarmoured trucks during this part of the war) are still to come.