doric-engine/main.py

47 lines
1.3 KiB
Python
Raw Permalink Normal View History

from kivy import app, properties
from kivy.uix.boxlayout import BoxLayout
2016-11-15 09:19:41 -05:00
from kivy.graphics import Color, Rectangle
2016-11-15 12:10:47 -05:00
from doric.tiles import MapTile, SpacerTile
class StrategyGame(BoxLayout):
main_map = properties.ObjectProperty(None)
status = properties.ObjectProperty(None)
map_rows = properties.NumericProperty(0)
map_cols = properties.NumericProperty(0)
def __init__(self, **kwargs):
super(StrategyGame, self).__init__(**kwargs)
for row in range(0, self.map_rows):
hex_map_row = BoxLayout(orientation='horizontal')
if row % 2 == 1:
2016-11-15 12:10:47 -05:00
hex_map_row.add_widget(SpacerTile())
for col in range(0, self.map_cols):
2016-11-15 12:10:47 -05:00
map_tile = MapTile(row=row, col=col)
hex_map_row.add_widget(map_tile)
if row % 2 == 0:
2016-11-15 12:10:47 -05:00
hex_map_row.add_widget(SpacerTile())
self.main_map.add_widget(hex_map_row)
2016-11-15 19:54:46 -05:00
def on_selected_cell(self, selected_tile, *args):
2016-11-15 09:19:41 -05:00
self.status.text = selected_tile.map_display_text()
with self.status.canvas.before:
2016-11-15 09:19:41 -05:00
Color(*selected_tile.terrain_colour)
Rectangle(pos=self.status.pos, size=self.status.size)
return True
class StrategyGameApp(app.App):
2016-06-04 14:31:07 -04:00
def build(self):
2016-06-04 14:59:40 -04:00
return StrategyGame()
2016-06-04 14:31:07 -04:00
if __name__ == '__main__':
2016-06-04 14:59:40 -04:00
StrategyGameApp().run()