Mercurial > zrpn
changeset 62:0a3b44b8d303
adding caption and title of game
| author | Rene Dudfield <renesd@gmail.com> |
|---|---|
| date | Sun, 08 Jul 2012 10:55:19 +0200 |
| parents | 1640501ecaae (current diff) 93a7da8e0e9a (diff) |
| children | 21049efe1631 783ad2376233 |
| files | zrpn/main.py |
| diffstat | 2 files changed, 35 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/zrpn/display.py Sun Jul 08 10:46:39 2012 +0200 +++ b/zrpn/display.py Sun Jul 08 10:55:19 2012 +0200 @@ -3,13 +3,16 @@ import pygame +import sgc.surface + import sprites class Display(object): def __init__(self): pygame.display.init() - self.screen = pygame.display.set_mode((800, 600)) + pygame.font.init() + self.screen = sgc.surface.Screen((800, 600)) self.screen.fill((0x33, 0x33, 0x33)) self.background = self.screen.copy() self.sprites = pygame.sprite.LayeredDirty()
--- a/zrpn/main.py Sun Jul 08 10:46:39 2012 +0200 +++ b/zrpn/main.py Sun Jul 08 10:55:19 2012 +0200 @@ -4,14 +4,19 @@ import pygame import sys +import sgc +from sgc.locals import * + import board import display +screen = display.Display() + class Game(object): - def __init__(self): + def __init__(self, display): self.board = board.Board() - self.display = display.Display() + self.display = display self.display.load_board(self.board.board, self.board.cells) def run(self): @@ -29,9 +34,32 @@ self.display.do_animations(animations) self.display.frame() +class MainMenu(sgc.Menu): + func_dict = lambda self: {"single": self.single, "multi": self.multi, + "exit": sys.exit} + + def single(self): + self.remove() + Game(screen).run() + + def multi(self): + raise NotImplementedError("Add multiplayer") + +menu = MainMenu(menu=("m:Zombies Robots Pirates Ninjas", ("f:single", "Single Player"), + ("f:multi", "Multiplayer"), ("f:exit", "Quit"))) def main(): - Game().run() + + pygame.display.set_caption("Zombies Robots Pirates Ninjas") + + clock = pygame.time.Clock() + menu.add(0) + while True: + time = clock.tick(30) + sgc.update(time) + for event in pygame.event.get(): + sgc.event(event) + pygame.display.flip() if __name__ == '__main__': main()
