Quick gist of a checkerboard.
This commit is contained in:
parent
81b17bef75
commit
f727ba7843
|
@ -10,8 +10,11 @@ import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from kivy import properties
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
from kivy.logger import Logger
|
from kivy.logger import Logger
|
||||||
|
from kivy.uix.image import Image
|
||||||
|
from kivy.uix.gridlayout import GridLayout
|
||||||
|
|
||||||
import justcheckers
|
import justcheckers
|
||||||
|
|
||||||
|
@ -49,6 +52,22 @@ class JustCheckersApp(App):
|
||||||
settings.add_json_panel("justCheckers Settings", self.config, data=json.dumps(game_settings))
|
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():
|
def log_system_and_game_info():
|
||||||
"""Logs information about the game and system running the game."""
|
"""Logs information about the game and system running the game."""
|
||||||
Logger.info('justCheckers -- v{}'.format(justcheckers.__version__))
|
Logger.info('justCheckers -- v{}'.format(justcheckers.__version__))
|
||||||
|
|
|
@ -76,12 +76,36 @@ ScreenManager:
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: "vertical"
|
orientation: "vertical"
|
||||||
Label:
|
Label:
|
||||||
text: "Game"
|
size_hint_y: 0.1
|
||||||
Button:
|
BoxLayout:
|
||||||
text: "Back to Menu"
|
orientation: "horizontal"
|
||||||
on_press:
|
size_hint_x: 0.9
|
||||||
root.manager.transition.direction = 'right'
|
pos_hint: {'center_x': 0.5}
|
||||||
root.manager.current = 'menu'
|
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>:
|
<InfoScreen@Screen>:
|
||||||
name: 'info'
|
name: 'info'
|
||||||
|
@ -126,3 +150,8 @@ ScreenManager:
|
||||||
if self.state == 'down': root.documentation = 'license'
|
if self.state == 'down': root.documentation = 'license'
|
||||||
Label:
|
Label:
|
||||||
size_hint_y: 0.1
|
size_hint_y: 0.1
|
||||||
|
|
||||||
|
|
||||||
|
<GameBoard@GridLayout>:
|
||||||
|
rows: 8
|
||||||
|
cols: 8
|
||||||
|
|
Loading…
Reference in New Issue