Merge branch 'llfkj' of https://github.com/llf-amy/gamecamp into llfkj

This commit is contained in:
Amy Wooding 2016-07-16 16:26:41 -04:00
commit 6e4c3a0b0b
2 changed files with 11 additions and 4 deletions

13
main.py
View File

@ -27,7 +27,7 @@ class StrategyGame(FloatLayout):
self.main_map.add_widget(hex_cell) self.main_map.add_widget(hex_cell)
# Add overlay conditionally. # 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)) print('({}, {})'.format(row, col))
# Determine the location of the solid hexagon cell. Needs to be offset from the centre of the hex. # Determine the location of the solid hexagon cell. Needs to be offset from the centre of the hex.
@ -48,8 +48,9 @@ class StrategyGame(FloatLayout):
Color(1, 1, 1, 1) Color(1, 1, 1, 1)
hex_cell.coord_label = Label( 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. # 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) hex_cell.bind(pos=hex_cell.update_pos, size=hex_cell.update_pos)
@ -63,6 +64,12 @@ class HexMapCell(Label):
def coordinate_text(self): def coordinate_text(self):
return '({}, {})'.format(self.coords.row, self.coords.col) 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): def update_pos(self, instance, value):
# Determine the location of the solid hexagon cell. Needs to be offset from the centre of the hex. # Determine the location of the solid hexagon cell. Needs to be offset from the centre of the hex.
radius = 2 * self.height radius = 2 * self.height

View File

@ -4,7 +4,7 @@
<StrategyGame>: <StrategyGame>:
id: _game id: _game
main_map: _main_map main_map: _main_map
map_rows: 30 map_rows: 15
map_cols: 10 map_cols: 10
BoxLayout: BoxLayout:
orientation: 'horizontal' orientation: 'horizontal'