Mercurial > sypikslang
diff gamelib/main.py @ 53:655a6912e0ae
Split gui stuff out of main.py
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Mon, 07 May 2012 22:10:26 +0200 |
parents | 1d3d20bdc8b9 |
children | a253fae32a6f |
line wrap: on
line diff
--- a/gamelib/main.py Mon May 07 21:55:55 2012 +0200 +++ b/gamelib/main.py Mon May 07 22:10:26 2012 +0200 @@ -7,67 +7,15 @@ ''' import pygame -from gamelib.gui_base import Window -from gamelib.gui import BigButton -from gamelib.engine import Engine, AddWindow, PopWindow +from gamelib.engine import Engine +from gamelib.mainmenu import MainMenu -from gamelib.constants import WIDTH, HEIGHT, SCREEN +from gamelib.constants import SCREEN pygame.init() -class ExitGameButton(BigButton): - - def __init__(self): - super(ExitGameButton, self).__init__(((WIDTH - 128), 10), 'Exit') - - def on_click(self): - PopWindow.post() - - -class GameWindow(Window): - """Main window for the game""" - - def __init__(self, screen): - super(GameWindow, self).__init__(screen) - exit = ExitGameButton() - self.add_child(exit) - - -class StartButton(BigButton): - - def __init__(self, screen): - super(StartButton, self).__init__(((WIDTH - 128) / 2, HEIGHT / 2), - 'Start') - self.screen = screen - - def on_click(self): - game_window = GameWindow(self.screen) - AddWindow.post(game_window) - - -class QuitButton(BigButton): - - def __init__(self): - super(QuitButton, self).__init__(((WIDTH - 128) / 2, - HEIGHT / 2 + 100), 'Quit') - - def on_click(self): - pygame.event.post(pygame.event.Event(pygame.QUIT)) - - -class MainMenu(Window): - - def __init__(self, screen): - super(MainMenu, self).__init__(screen) - self.background_colour = (0, 0, 0) - button1 = StartButton(screen) - self.add_child(button1) - button2 = QuitButton() - self.add_child(button2) - - def main(): screen = pygame.display.set_mode(SCREEN) engine = Engine(screen)