Use labels, to make things look better
authorNeil <neil@dip.sun.ac.za>
Wed, 17 Apr 2013 12:21:45 +0000 (14:21 +0200)
committerNeil <neil@dip.sun.ac.za>
Wed, 17 Apr 2013 12:21:45 +0000 (14:21 +0200)
erdslangetjie/__main__.py

index 0141bd97ce3cd02f176ac332a566917c4a7a0b90..e6bc2ce169f096958636cdaba8914651b0162cfd 100644 (file)
@@ -8,7 +8,7 @@ from kivy.uix.widget import Widget
 from kivy.logger import Logger, LoggerHistory
 from kivy.uix.relativelayout import RelativeLayout
 from kivy.uix.scrollview import ScrollView
-from kivy.uix.button import Button
+from kivy.uix.label import Label
 from kivy.graphics import Color, Rectangle
 from kivy.utils import platform
 
@@ -173,6 +173,8 @@ class GameWindow(RelativeLayout):
             self.do_move(direction)
 
     def do_move(self, direction):
+        if not self.level_obj:
+            return
         self.nemesis.move(self.level_obj)
         self.draw_nemesis()
         self.player.move(direction, self.level_obj)
@@ -181,6 +183,8 @@ class GameWindow(RelativeLayout):
         self.reset_timer()
 
     def timed_move(self):
+        if not self.level_obj:
+            return
         self.nemesis.move(self.level_obj)
         self.draw_nemesis()
         self.check_state()
@@ -247,14 +251,19 @@ class Screen(Widget):
             Rectangle(pos=(0, 0), size=(1026, 760),
                     texture=self.image.texture)
 
-        self.stop_button = Button(
-                text='Quit', size=(200, 40),
+        self.stop_button = Label(
+                text='[ref=quit][color=ff0066]Quit[/color][/ref]',
+                font_size=30,
+                markup=True,
+                size=(200, 40),
                 pos=((1026 - 200) / 2 - 100, 100))
-        self.stop_button.bind(on_press=self.app.stop_app)
-        self.start_button = Button(
-                text=self.START, size=(200, 40),
+        self.stop_button.bind(on_ref_press=self.app.stop_app)
+        self.start_button = Label(
+                text="[ref=start][color=00ff66]" + self.START + "[/color][/ref]",
+                font_size=30,
+                markup = True, size=(200, 40),
                 pos=((1026 - 200) / 2 + 100, 100))
-        self.start_button.bind(on_press=self.app.start_game)
+        self.start_button.bind(on_ref_press=self.app.start_game)
         self.add_widget(self.stop_button)
         self.add_widget(self.start_button)
 
@@ -302,10 +311,10 @@ class GameApp(App):
         screen = IntroScreen(self)
         self.root.add_widget(screen)
 
-    def stop_app(self, button):
+    def stop_app(self, label, ref):
         self.stop()
 
-    def start_game(self, button):
+    def start_game(self, label, ref):
         """Start the game"""
         game = GameWindow(self.levels, self)
         game.build()