Draw menu items
authorNeil <neil@dip.sun.ac.za>
Thu, 8 Sep 2016 10:11:00 +0000 (12:11 +0200)
committerNeil <neil@dip.sun.ac.za>
Thu, 8 Sep 2016 10:11:00 +0000 (12:11 +0200)
tabakrolletjie/scenes/menu.py

index ed7cc3194ff34105a08ef3c5c1630f549502502a..0492ae9e38c42083ef506d0f42d8b6e5dbcdafd8 100644 (file)
@@ -4,6 +4,8 @@ import pygame.locals as pgl
 
 from .base import BaseScene
 from ..events import QuitEvent, SceneChangeEvent
+from ..loader import loader
+from ..constants import FONTS
 
 
 class MenuScene(BaseScene):
@@ -11,9 +13,26 @@ class MenuScene(BaseScene):
         if gamestate.station is None:
             print "Loading Station Alpha ..."
             gamestate.load_station("station-alpha.json")
+        font_title = loader.load_font(FONTS['bold'], size=32)
+        self._title = font_title.render('A Game with a title', True,
+                                        (255, 255, 255))
+        font_menu = loader.load_font(FONTS['sans'], size=24)
+        self._menu = [
+            font_menu.render("Load Level", True, (255, 255, 255)),
+            font_menu.render("Load Saved Game", True, (255, 255, 255)),
+            ]
 
     def render(self, surface, gamestate):
-        surface.fill((0, 255, 0))
+        surface.fill((0, 128, 0))
+
+        pos = ((surface.get_width() - self._title.get_width()) / 2, 50)
+        surface.blit(self._title, pos, None)
+
+        height = 150
+        for item in self._menu:
+            pos = ((surface.get_width() - item.get_width()) / 2, height)
+            surface.blit(item, pos, None)
+            height += 50
 
     def event(self, ev, gamestate):
         if ev.type == pgl.KEYDOWN: