Changeset 179:e2b5262c2b11


Ignore:
Timestamp:
Sep 4, 2009, 3:00:54 PM (11 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Convert:
svn:b4e93282-eac8-4b8b-b765-0f5d36de2b68@180
Message:

Add basic help screen

Location:
gamelib
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • gamelib/engine.py

    r162 r179  
    1010import constants
    1111import mainmenu
     12import helpscreen
    1213
    1314class Engine(Game):
     
    3839        self.open_window(self.main_menu)
    3940
     41    def set_help_screen(self):
     42        """Open the main menu"""
     43        help_screen = helpscreen.make_help_screen()
     44        self.open_window(help_screen)
     45
    4046    def create_game_over(self):
    4147        """Create and open the Game Over window"""
     
    5258            self.game.create_game_board()
    5359            return DayState(self.game)
     60        elif events_equal(e, GO_HELP_SCREEN):
     61            return HelpScreenState(self.game)
    5462        elif e.type is KEYDOWN:
    5563            if e.key == K_ESCAPE:
     
    5866                self.game.create_game_board()
    5967                return DayState(self.game)
     68        elif e.type is not QUIT:
     69            self.game.main_app.event(e)
     70
     71    def paint(self, screen):
     72        screen.fill((0,0,0))
     73        self.game.main_app.paint(screen)
     74        pygame.display.flip()
     75
     76    def update(self, screen):
     77        update = self.game.main_app.update(screen)
     78        pygame.display.update(update)
     79
     80class HelpScreenState(State):
     81    def init(self):
     82        sound.stop_background_music()
     83        self.game.set_help_screen()
     84
     85    def event(self, e):
     86        if e.type is KEYDOWN and e.key == K_ESCAPE:
     87                return MainMenu(self.game)
     88        elif events_equal(e, GO_MAIN_MENU):
     89            return MainMenuState(self.game)
    6090        elif e.type is not QUIT:
    6191            self.game.main_app.event(e)
     
    190220START_NIGHT = pygame.event.Event(USEREVENT, name="START_NIGHT")
    191221GO_MAIN_MENU = pygame.event.Event(USEREVENT, name="GO_MAIN_MENU")
     222GO_HELP_SCREEN = pygame.event.Event(USEREVENT, name="GO_HELP_SCREEN")
    192223MOVE_FOX_ID = USEREVENT + 1
    193224MOVE_FOXES = pygame.event.Event(MOVE_FOX_ID, name="MOVE_FOXES")
  • gamelib/mainmenu.py

    r151 r179  
    3636            pygame.event.post(engine.START_DAY)
    3737
     38        def help_pressed():
     39            pygame.event.post(engine.GO_HELP_SCREEN)
     40
    3841        start_button = gui.Button("Start")
    3942        start_button.connect(gui.CLICK, start_pressed)
     
    4144        quit_button = gui.Button("Quit")
    4245        quit_button.connect(gui.CLICK, quit_pressed)
     46
     47        help_button = gui.Button("Instructions")
     48        help_button.connect(gui.CLICK, help_pressed)
    4349
    4450        fullscreen_toggle = gui.Button("Toggle Fullscreen")
     
    5763
    5864        self.tr()
     65        self.td(help_button, **td_kwargs)
     66
     67        self.tr()
    5968        self.td(fullscreen_toggle, **td_kwargs)
    6069
Note: See TracChangeset for help on using the changeset viewer.