Minor code clean up.
This commit is contained in:
parent
0bdf4f126d
commit
c57c01464d
23
main.py
23
main.py
|
@ -1,14 +1,10 @@
|
||||||
import collections
|
import collections
|
||||||
import random
|
|
||||||
import math
|
|
||||||
|
|
||||||
from kivy import app, properties
|
from kivy import app, properties
|
||||||
from kivy.uix import button, label
|
from kivy.uix import label
|
||||||
from kivy.uix.floatlayout import FloatLayout
|
from kivy.uix.floatlayout import FloatLayout
|
||||||
from kivy.graphics import Color, Ellipse, Line
|
from kivy.graphics import Color, Ellipse, Line
|
||||||
from kivy.logger import Logger
|
|
||||||
import kivy.utils
|
import kivy.utils
|
||||||
from kivy.vector import Vector
|
|
||||||
|
|
||||||
MapCoords = collections.namedtuple('MapCoords', ['row', 'col'])
|
MapCoords = collections.namedtuple('MapCoords', ['row', 'col'])
|
||||||
|
|
||||||
|
@ -33,7 +29,6 @@ class StrategyGame(FloatLayout):
|
||||||
# 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):
|
||||||
print('({}, {})'.format(row, col))
|
print('({}, {})'.format(row, col))
|
||||||
#radius = math.sqrt(hex_cell.width**2 + hex_cell.height**2)
|
|
||||||
radius = 2 * hex_cell.height
|
radius = 2 * hex_cell.height
|
||||||
solid_x = hex_cell.x - hex_cell.height*2
|
solid_x = hex_cell.x - hex_cell.height*2
|
||||||
solid_y = hex_cell.y - hex_cell.height*2
|
solid_y = hex_cell.y - hex_cell.height*2
|
||||||
|
@ -52,7 +47,6 @@ class HexMapCell(label.Label):
|
||||||
self.coords = MapCoords(row, col)
|
self.coords = MapCoords(row, col)
|
||||||
|
|
||||||
def update_pos(self, instance, value):
|
def update_pos(self, instance, value):
|
||||||
#radius = math.sqrt(self.width**2 + self.height**2)
|
|
||||||
radius = 2 * self.height
|
radius = 2 * self.height
|
||||||
solid_x = self.x - self.height*2
|
solid_x = self.x - self.height*2
|
||||||
solid_y = self.y - self.height*2
|
solid_y = self.y - self.height*2
|
||||||
|
@ -61,21 +55,6 @@ class HexMapCell(label.Label):
|
||||||
self.solid.pos = (solid_x, solid_y)
|
self.solid.pos = (solid_x, solid_y)
|
||||||
self.solid.size = solid_size
|
self.solid.size = solid_size
|
||||||
|
|
||||||
class HexMapControlCell(button.Button):
|
|
||||||
def __init__(self, hex_bind=None, **kwargs):
|
|
||||||
super(HexMapControlCell, self).__init__(**kwargs)
|
|
||||||
self.hex_bind = hex_bind
|
|
||||||
self.background_color = random.random(), random.random(), random.random(), 1
|
|
||||||
self.bind(pos=self.reposition_control_cell, size=self.resize_control_cell)
|
|
||||||
self.text = '({}, {})'.format(self.hex_bind.coords.row, self.hex_bind.coords.col)
|
|
||||||
|
|
||||||
def reposition_control_cell(self, obj, value):
|
|
||||||
self.pos = self.hex_bind.pos
|
|
||||||
|
|
||||||
def resize_control_cell(self, obj, value):
|
|
||||||
self.height = self.hex_bind.height * 2
|
|
||||||
self.width = self.hex_bind.width * 2
|
|
||||||
|
|
||||||
|
|
||||||
class StrategyGameApp(app.App):
|
class StrategyGameApp(app.App):
|
||||||
def build(self):
|
def build(self):
|
||||||
|
|
Loading…
Reference in New Issue