Mercurial > skaapsteker
view skaapsteker/menuscene.py @ 365:a43f571e8f5b
Dim cutscene background
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Sat, 09 Apr 2011 14:39:18 +0200 |
parents | e006ec7b3d8f |
children | 8631e38afc24 |
line wrap: on
line source
import pygame from pygame.locals import K_ESCAPE, K_q, KEYDOWN, QUIT from .cutscene import opening_cutscene from .engine import ChangeScene, Scene from .levelscene import LevelScene from .widgets.text import Text, TextChoice class MenuScene(Scene): def __init__(self, game_state, soundsystem, cur_game=None): super(MenuScene, self).__init__(game_state, soundsystem) self.widgets.append(Text("MENU:", (50, 50), color='white', size=48)) self.cur_game = cur_game menu_options = [ ('Starting Cutscene', 'cutscene'), ('Temple', 'temple.starting'), ("Temple grounds", "temple_grounds.starting"), ("Road", "road.starting"), ("Town", "town.starting"), ("Tea house", "tea_house.starting"), ("Kumiko's rooms", "geisha_room.starting"), ("Market", "market.starting"), ("Fishmonger's house", "fishmonger_house.starting"), ("Theatre", "theatre.starting"), ("Celestial plane", "celestial_plane.starting"), ('Quit', 'quit'), ] if cur_game is not None: menu_options.insert(0, ('Resume Game', 'resume')) self.choice = TextChoice(menu_options, (50, 100), color='white') self.choice.callbacks.append(self.selected) self.widgets.append(self.choice) def selected(self, option, data): "Callback from menu TextChoice" if data == 'resume': ChangeScene.post(self.cur_game) elif data == 'cutscene': ChangeScene.post(opening_cutscene(self.game_state, self._soundsystem)) elif data == 'quit': pygame.event.post(pygame.event.Event(QUIT)) else: ChangeScene.post(LevelScene(self.game_state, self._soundsystem, data)) def draw(self, surface, engine): surface.fill(pygame.Color('black')) super(MenuScene, self).draw(surface, engine) def dispatch(self, ev): if ev.type is KEYDOWN: if ev.key in(K_q, K_ESCAPE): pygame.event.post(pygame.event.Event(QUIT)) super(MenuScene, self).dispatch(ev)