comparison gamelib/engine.py @ 31:3c4db7bba432

Add 's' as a key for starting the game from the menu.
author Simon Cross <hodgestar@gmail.com>
date Sun, 30 Aug 2009 18:56:09 +0000
parents 2eec29085060
children 18db99fda6bd
comparison
equal deleted inserted replaced
30:2eec29085060 31:3c4db7bba432
1 """Game engine and states.""" 1 """Game engine and states."""
2 2
3 from pgu.engine import Game, State, Quit 3 from pgu.engine import Game, State, Quit
4 import pygame 4 import pygame
5 from pygame.locals import USEREVENT, QUIT, KEYDOWN, K_ESCAPE, K_n, K_d 5 from pygame.locals import USEREVENT, QUIT, KEYDOWN, K_ESCAPE, K_n, K_d, K_s
6 6
7 from tiles import TILE_MAP 7 from tiles import TILE_MAP
8 import gameboard 8 import gameboard
9 import animal 9 import animal
10 import random 10 import random
24 class MainMenuState(State): 24 class MainMenuState(State):
25 def event(self, e): 25 def event(self, e):
26 if events_equal(e, START_DAY): 26 if events_equal(e, START_DAY):
27 self.game.create_game_board() 27 self.game.create_game_board()
28 return DayState(self.game) 28 return DayState(self.game)
29 elif e.type is KEYDOWN and e.key == K_ESCAPE: 29 elif e.type is KEYDOWN:
30 return Quit(self.game) 30 if e.key == K_ESCAPE:
31 return Quit(self.game)
32 elif e.key == K_s:
33 self.game.create_game_board()
34 return DayState(self.game)
31 elif e.type is not QUIT: 35 elif e.type is not QUIT:
32 self.game.main_menu_app.event(e) 36 self.game.main_menu_app.event(e)
33 37
34 def paint(self, screen): 38 def paint(self, screen):
35 screen.fill((0,0,0)) 39 screen.fill((0,0,0))