Add a basic map coordinate system.

This commit is contained in:
Dorian 2016-07-16 16:11:26 -04:00
parent 2ad77a17d2
commit f806453bf6
1 changed files with 9 additions and 1 deletions

10
main.py
View File

@ -48,7 +48,9 @@ class StrategyGame(FloatLayout):
Color(1, 1, 1, 1)
hex_cell.coord_label = Label(
text=hex_cell.coordinate_text(), center_x=hex_cell.x, center_y=hex_cell.y)
text=hex_cell.map_display_text(),
center_x=hex_cell.x,
center_y=hex_cell.y)
# Bind the cell code so as to update its position and size when the parent widget resizes.
hex_cell.bind(pos=hex_cell.update_pos, size=hex_cell.update_pos)
@ -62,6 +64,12 @@ class HexMapCell(Label):
def coordinate_text(self):
return '({}, {})'.format(self.coords.row, self.coords.col)
def map_coordinate_text(self):
return '[{}, {}]'.format(self.coords.row / 3, self.coords.col / 2)
def map_display_text(self):
return "{}\n{}".format(self.coordinate_text(), self.map_coordinate_text())
def update_pos(self, instance, value):
# Determine the location of the solid hexagon cell. Needs to be offset from the centre of the hex.
radius = 2 * self.height