view nagslang/screens/menu.py @ 180:026297a03963

Add DoorEvent and tweak ScreenChange to keep more state when the player goes through a door
author Neil Muller <drnlmuller@gmail.com>
date Tue, 03 Sep 2013 16:58:45 +0200
parents 58505d3482b6
children e89a43d208b9
line wrap: on
line source

"""Display a menu screen."""

import pygame

from nagslang.screens.base import Screen
from nagslang.events import QuitEvent, ScreenChange
from nagslang.widgets.text import TextWidget


class MenuScreen(Screen):

    def handle_event(self, ev):
        if ev.type == pygame.locals.KEYDOWN:
            if ev.key == pygame.locals.K_ESCAPE:
                QuitEvent.post()
            elif ev.key == pygame.locals.K_1:
                ScreenChange.post('level1', None)

    def render(self, surface):
        surface.fill(pygame.color.Color(255, 255, 255))
        TextWidget((10, 10), 'Menu').draw(surface)
        TextWidget((10, 30), 'Press 1 to start').draw(surface)