Display player at the start
authorNeil <neil@dip.sun.ac.za>
Mon, 15 Apr 2013 10:56:47 +0000 (12:56 +0200)
committerNeil <neil@dip.sun.ac.za>
Mon, 15 Apr 2013 10:56:47 +0000 (12:56 +0200)
erdslangetjie/__main__.py

index 08d7154a09b356b98be3981aeb96468cfab17621..9802657cf1dc9bb22bb68c9fb59818c77d3d94a1 100644 (file)
@@ -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):