From 53d6a6c7ba5d02e2956df066d98dda59c81fb3d3 Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Sat, 16 Jul 2016 15:52:01 -0400 Subject: [PATCH 1/3] Avoid displaying cells cut off on the left. --- main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main.py b/main.py index 1627033..b2a9139 100644 --- a/main.py +++ b/main.py @@ -27,7 +27,7 @@ class StrategyGame(FloatLayout): self.main_map.add_widget(hex_cell) # Add overlay conditionally. - if (row % 6 == 1 and col % 2 == 1) or (row % 6 == 4 and col % 2 == 0): + if (row % 6 == 1 and col % 2 == 1) or (row % 6 == 4 and col % 2 == 0) and (col > 0): print('({}, {})'.format(row, col)) # Determine the location of the solid hexagon cell. Needs to be offset from the centre of the hex. @@ -50,7 +50,6 @@ class StrategyGame(FloatLayout): hex_cell.coord_label = Label( text=hex_cell.coordinate_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) From 2ad77a17d27248bed4cd3cc9cd075e2f1dd0a695 Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Sat, 16 Jul 2016 15:56:12 -0400 Subject: [PATCH 2/3] Change the number of hexes drawn overall. --- strategygame.kv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strategygame.kv b/strategygame.kv index 886890a..14d7ff8 100644 --- a/strategygame.kv +++ b/strategygame.kv @@ -4,7 +4,7 @@ : id: _game main_map: _main_map - map_rows: 30 + map_rows: 15 map_cols: 10 BoxLayout: orientation: 'horizontal' From f806453bf634b3fd1ececa2bb081fccf3aef0d30 Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Sat, 16 Jul 2016 16:11:26 -0400 Subject: [PATCH 3/3] Add a basic map coordinate system. --- main.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index b2a9139..4f66fca 100644 --- a/main.py +++ b/main.py @@ -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