From f727ba7843369c769b275c3aacef831ebffaa3ec Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Sun, 26 Feb 2017 19:28:39 -0500 Subject: [PATCH] Quick gist of a checkerboard. --- justcheckers/app.py | 19 +++++++++++++++++ justcheckers/justcheckers.kv | 41 ++++++++++++++++++++++++++++++------ 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/justcheckers/app.py b/justcheckers/app.py index b4e6e7a..3270ac2 100644 --- a/justcheckers/app.py +++ b/justcheckers/app.py @@ -10,8 +10,11 @@ import logging import os 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 import justcheckers @@ -49,6 +52,22 @@ class JustCheckersApp(App): settings.add_json_panel("justCheckers Settings", self.config, data=json.dumps(game_settings)) +class GameBoard(GridLayout): + rows = properties.NumericProperty(8) + cols = properties.NumericProperty(8) + + def __init__(self, **kwargs): + super(GameBoard, self).__init__(**kwargs) + for row in range(self.rows): + for col in range(self.cols): + source = 'play' + if row % 2 == 0 and col % 2 == 0: + source = 'non_play' + elif row % 2 == 1 and col % 2 == 1: + source = 'non_play' + self.add_widget(Image(source='images/{}.png'.format(source), allow_stretch=True)) + + def log_system_and_game_info(): """Logs information about the game and system running the game.""" Logger.info('justCheckers -- v{}'.format(justcheckers.__version__)) diff --git a/justcheckers/justcheckers.kv b/justcheckers/justcheckers.kv index cb83c2d..f304852 100644 --- a/justcheckers/justcheckers.kv +++ b/justcheckers/justcheckers.kv @@ -76,12 +76,36 @@ ScreenManager: BoxLayout: orientation: "vertical" Label: - text: "Game" - Button: - text: "Back to Menu" - on_press: - root.manager.transition.direction = 'right' - root.manager.current = 'menu' + size_hint_y: 0.1 + BoxLayout: + orientation: "horizontal" + size_hint_x: 0.9 + pos_hint: {'center_x': 0.5} + GameBoard: + id: game_board + size_hint_x: 0.75 + BoxLayout: + id: player_stats + size_hint_x: 0.25 + orientation: "vertical" + Button: + text: "Player 1" + Button: + text: "Player 2" + Label: + size_hint_y: 0.1 + BoxLayout: + orientation: "horizontal" + size_hint_x: 0.9 + size_hint_y: 0.1 + pos_hint: {'center_x': 0.5} + Button: + text: "Back to Menu" + on_press: + root.manager.transition.direction = 'right' + root.manager.current = 'menu' + Label: + size_hint_y: 0.1 : name: 'info' @@ -126,3 +150,8 @@ ScreenManager: if self.state == 'down': root.documentation = 'license' Label: size_hint_y: 0.1 + + +: + rows: 8 + cols: 8