Quick gist of a checkerboard.

This commit is contained in:
Dorian 2017-02-26 19:28:39 -05:00
parent 81b17bef75
commit f727ba7843
2 changed files with 54 additions and 6 deletions

View File

@ -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__))

View File

@ -76,12 +76,36 @@ ScreenManager:
BoxLayout:
orientation: "vertical"
Label:
text: "Game"
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
<InfoScreen@Screen>:
name: 'info'
@ -126,3 +150,8 @@ ScreenManager:
if self.state == 'down': root.documentation = 'license'
Label:
size_hint_y: 0.1
<GameBoard@GridLayout>:
rows: 8
cols: 8