Simplify hex map creation.
This commit is contained in:
parent
b7346b713a
commit
2aaa27a824
|
@ -33,29 +33,21 @@ class HexMap(Widget):
|
||||||
|
|
||||||
for y in range(tiles_in_col):
|
for y in range(tiles_in_col):
|
||||||
|
|
||||||
if y % 2 == 0:
|
even_row = y % 2 == 0
|
||||||
hex_color = "#0000dd55"
|
hex_color = "#0000dd55" if even_row else "#dd000055"
|
||||||
even_row = True
|
tiles_in_row = tiles_in_even_row if even_row else tiles_in_odd_row
|
||||||
tiles_in_row = tiles_in_even_row
|
|
||||||
else:
|
y_position = y * HEX_SIZE * VERTICAL_BUFFER
|
||||||
hex_color = "#dd000055"
|
|
||||||
even_row = False
|
|
||||||
tiles_in_row = tiles_in_odd_row
|
|
||||||
|
|
||||||
for x in range(tiles_in_row):
|
for x in range(tiles_in_row):
|
||||||
Color(*get_color_from_hex(hex_color))
|
Color(*get_color_from_hex(hex_color))
|
||||||
|
|
||||||
if even_row:
|
x_position = x * HEX_SIZE * HORIZONTAL_BUFFER
|
||||||
Ellipse(
|
if not even_row:
|
||||||
pos=(x * HEX_SIZE * HORIZONTAL_BUFFER, y * HEX_SIZE * VERTICAL_BUFFER),
|
x_position += 0.5 * HEX_SIZE * HORIZONTAL_BUFFER
|
||||||
segments=6,
|
|
||||||
size=(HEX_SIZE, HEX_SIZE),
|
|
||||||
)
|
|
||||||
|
|
||||||
else:
|
|
||||||
Ellipse(
|
Ellipse(
|
||||||
pos=((x * HEX_SIZE * HORIZONTAL_BUFFER) + (0.5 * HEX_SIZE * HORIZONTAL_BUFFER),
|
pos=(x_position, y_position),
|
||||||
y * HEX_SIZE * VERTICAL_BUFFER),
|
|
||||||
segments=6,
|
segments=6,
|
||||||
size=(HEX_SIZE, HEX_SIZE),
|
size=(HEX_SIZE, HEX_SIZE),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue