# HG changeset patch # User Neil Muller # Date 1282488625 -7200 # Node ID 55f1969e41c979740975a2863c2ee7003ad785ae # Parent a02dc1e26c603e39f1b7cc85f3b080b4b6d6b789 Add simple menu screen diff -r a02dc1e26c60 -r 55f1969e41c9 gamelib/main.py --- a/gamelib/main.py Sun Aug 22 16:31:21 2010 +0200 +++ b/gamelib/main.py Sun Aug 22 16:50:25 2010 +0200 @@ -2,12 +2,25 @@ Contains the entry point used by the run_game.py script. -Feel free to put all your game code here, or in other modules in this "gamelib" -package. ''' import data +import pygame +from pygame.locals import SWSURFACE, SRCALPHA +from albow.dialogs import alert +from albow.shell import Shell +from menu import MenuScreen + +class MainShell(Shell): + def __init__(self, display): + Shell.__init__(self, display) + self.menu_screen = MenuScreen(self) + self.show_screen(self.menu_screen) + def main(): - print "Hello from your game's main()" - print data.load('sample.txt').read() + pygame.init() + display = pygame.display.set_mode((800, 600)) + shell = MainShell(display) + shell.run() + diff -r a02dc1e26c60 -r 55f1969e41c9 gamelib/menu.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gamelib/menu.py Sun Aug 22 16:50:25 2010 +0200 @@ -0,0 +1,26 @@ +# menu.py +# Copyright Boomslang team, 2010 (see COPYING File) +# Main menu for the game + +from albow.screen import Screen +from albow.controls import Button, Label +from albow.layout import Column + +class MenuScreen(Screen): + def __init__(self, shell): + Screen.__init__(self, shell) + self.shell = shell + StartButton = Button('Start New Game', action = self.start) + QuitButton = Button('Quit', action = shell.quit) + Title = Label('Caught! ... In SPAACE') + menu = Column([ + Title, + StartButton, + QuitButton, + ], align='l', spacing=20) + self.add_centered(menu) + + def start(self): + print 'Starting the game' + +