3 import pygame.locals as pgl
5 from .base import BaseScene
6 from ..events import QuitEvent, SceneChangeEvent
7 from ..loader import loader
8 from ..constants import FONTS
11 class MenuScene(BaseScene):
12 def enter(self, gamestate):
13 if gamestate.station is None:
14 print "Loading Station Alpha ..."
15 gamestate.load_station("station-alpha.json")
16 font_title = loader.load_font(FONTS['bold'], size=32)
17 self._title = font_title.render('A Game with a title', True,
19 font_menu = loader.load_font(FONTS['sans'], size=24)
21 font_menu.render("Load Level", True, (255, 255, 255)),
22 font_menu.render("Load Saved Game", True, (255, 255, 255)),
25 def render(self, surface, gamestate):
26 surface.fill((0, 128, 0))
28 pos = ((surface.get_width() - self._title.get_width()) / 2, 50)
29 surface.blit(self._title, pos, None)
32 for item in self._menu:
33 pos = ((surface.get_width() - item.get_width()) / 2, height)
34 surface.blit(item, pos, None)
37 def event(self, ev, gamestate):
38 if ev.type == pgl.KEYDOWN:
39 if ev.key in (pgl.K_q, pgl.K_ESCAPE):
41 elif ev.key == pgl.K_n:
42 from .night import NightScene
43 SceneChangeEvent.post(scene=NightScene())
44 elif ev.key == pgl.K_d:
45 from .day import DayScene
46 SceneChangeEvent.post(scene=DayScene())
47 elif ev.key == pgl.K_l:
48 print "Loading Station Alpha ..."
49 gamestate.load_station("station-alpha.json")