From: Neil Date: Mon, 15 Apr 2013 10:56:47 +0000 (+0200) Subject: Display player at the start X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=6200dd009a7eb6102fd5e0c0170f274f736ecc25;p=erdslangetjie.git Display player at the start --- diff --git a/erdslangetjie/__main__.py b/erdslangetjie/__main__.py index 08d7154..9802657 100644 --- a/erdslangetjie/__main__.py +++ b/erdslangetjie/__main__.py @@ -11,6 +11,7 @@ from kivy.graphics import Color, Rectangle from erdslangetjie.data import filepath, load from erdslangetjie.level import Level +from erdslangetjie.player import ThePlayer, Nemesis class GameWindow(FloatLayout): @@ -30,6 +31,13 @@ class GameWindow(FloatLayout): self.level_obj.load(level_data) level_data.close() + self.player = ThePlayer() + self.level_obj.load_tiles() + if not self.level_obj.enter_pos: + raise RuntimeError('No entry point') + + self.player.pos = self.level_obj.enter_pos + def build(self): self.clear_widgets() tiles = self.level_obj.get_tiles() @@ -47,6 +55,16 @@ class GameWindow(FloatLayout): bx += tile_size by += tile_size + player_pos = (self.player.pos[0] * tile_size, + self.player.pos[1] * tile_size) + player_tile = Widget(size=(tile_size, tile_size), + pos=player_pos) + with player_tile.canvas: + Color(1, 1, 1) + Rectangle(pos=player_pos, size=player_tile.size, + texture=self.player.sprite.texture) + self.add_widget(player_tile) + class GameApp(App):