From: Neil Date: Thu, 8 Sep 2016 10:11:00 +0000 (+0200) Subject: Draw menu items X-Git-Tag: tabakrolletjie-v1.0.0~187 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=3dd84f63b3435d92e08c39d6a46fb8179a7b43a2;p=tabakrolletjie.git Draw menu items --- diff --git a/tabakrolletjie/scenes/menu.py b/tabakrolletjie/scenes/menu.py index ed7cc31..0492ae9 100644 --- a/tabakrolletjie/scenes/menu.py +++ b/tabakrolletjie/scenes/menu.py @@ -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: