The heart of the game proper is the Board: the surface or landscape the game units will be playing on.
This being Battletech, the Board is naturally going to be a hexagon-based grid. Nearly all of the logic so far built for the Board's hex logic/maths have been taken from here, as well as much help from a couple of the guys from the BA forums.
Each hex is represented by a Tile object. In the future, this will hold all information about that hex (terrain, elevation, units present, etc etc). For now, it holds both axial ('hex') and cubic coordinates.
For now, the Board's hex logic can do the following:
- Draw a 'line of sight' between two hexes, as well as find the Manhattan distance between them, in hexes.
- Find the hexes within a radius of a single hex.
With the line of sight calculation, and logic to determine the positions of units on the board, all should be in place to begin basic combat mechanics. To fire a weapon, you need to determine positions of attacker and defender, line of sight between the two, and range (coupled with weapons ranges of course).
The big snag at the moment is calculating arcs of fire. Simple vector calculations to other units relative to the attacker could get the job done, but not in as visually-informative way as I would like. Eventually, I would like to be able to highlight the hexes within the arc of fire (as well as being able to set forward/left/right/rear arcs to display). The answer is there, I just haven't found an adequate solution yet.
The Board can support maps of any rectangular dimension. The Board's script will generate a board on-the-fly.
A 'map editor' of sorts could be developed with bpy to enable in-Blender map creation. Initial attempts were to create an in-game editor that could run beside the game proper, but this proves to be cumbersome.
In principle, the Board should come in two 'layers'. The Tactical layer, and the Physical layer. The Tactical layer is where the actual hex grid construct is. The core logic of the game's mechanics and rules use the Tactical layer. This should also be 'overlayed' (with an option to toggle it's visibility?) on top of the Physical layer in order to give the player a visual sense of the Board's hexes.
The logic for this can be set up rather simply. To get the Physical equivelant of a hex's space, an object above that hex fires a Ray downward, picking up the hitPosition on the Physical terrain. Physical units will use these postions as targets for their movement, as they follow their 'ghost' units, which are used by the player to input orders for movement and weapons fire.
The Physical layer will be the naturally-sculpted terrain and visual unit models that visualize the 'real-world' representation of the Board's layout. These can be hand-sculpted and painted by the map designer (in parallel with the in-editor map editor!). I'm sure a script could also be written to generate these terrains using Board data as well, which would at least give the artist a good starting point, rather than sculpting the entire thing by hand.