From 3dd84f63b3435d92e08c39d6a46fb8179a7b43a2 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 8 Sep 2016 12:11:00 +0200 Subject: [PATCH 1/1] Draw menu items --- tabakrolletjie/scenes/menu.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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: -- 2.34.1