diff --git a/justcheckers/app.py b/justcheckers/app.py index 11aaeb4..3eea01e 100644 --- a/justcheckers/app.py +++ b/justcheckers/app.py @@ -13,8 +13,8 @@ import sys from kivy import properties from kivy.app import App from kivy.logger import Logger -from kivy.uix.image import Image from kivy.uix.gridlayout import GridLayout +from kivy.uix.relativelayout import RelativeLayout import justcheckers @@ -65,11 +65,21 @@ class GameBoard(GridLayout): source = 'non_play' elif row % 2 == 1 and col % 2 == 1: source = 'non_play' - self.add_widget(GameTile(source='images/{}.png'.format(source))) + self.add_widget(GameTile(tile_state=source, coords=[row, col])) -class GameTile(Image): - pass +class GameTile(RelativeLayout): + tile_state = properties.StringProperty() + tile_coords = properties.ListProperty() + tile_image = properties.ObjectProperty() + tile_label = properties.ObjectProperty() + + def __init__(self, tile_state='non_play', coords=None, **kwargs): + super(GameTile, self).__init__(**kwargs) + self.tile_state = tile_state + self.coords = coords if coords else [-1, -1] + self.tile_label.text = '{}, {}'.format(self.coords[0], self.coords[1]) + self.tile_image.source = 'images/{}.png'.format(self.tile_state) def log_system_and_game_info(): diff --git a/justcheckers/justcheckers.kv b/justcheckers/justcheckers.kv index ecd45f9..e630d12 100644 --- a/justcheckers/justcheckers.kv +++ b/justcheckers/justcheckers.kv @@ -162,12 +162,16 @@ ScreenManager: col_default_width: 50 -: - source: "images/play.png" - allow_stretch: True - canvas.after: - Color: - rgba: [0, 1, 1, 0.75] - Ellipse: - pos: self.pos - size: self.width - 5, self.height / 2 +: + tile_state: "play" + tile_coords: 0, 0 + tile_image: image + tile_label: label + Image: + id: image + allow_stretch: True + Label: + id: label + color: [1, 0, 0, 0.75] + font_size: "20sp" +