Mercurial > boomslang
diff gamelib/gamescreen.py @ 29:6322d92dc8f0
Add state widget for rendering state.
author | Simon Cross <hodgestar+bzr@gmail.com> |
---|---|
date | Sun, 22 Aug 2010 19:20:58 +0200 |
parents | 0f25f7b9b37a |
children | e5c043aeed65 |
line wrap: on
line diff
--- a/gamelib/gamescreen.py Sun Aug 22 18:48:32 2010 +0200 +++ b/gamelib/gamescreen.py Sun Aug 22 19:20:58 2010 +0200 @@ -5,8 +5,9 @@ from state import initial_state from pygame.color import Color +from pygame import Rect from albow.screen import Screen -from albow.controls import Button, Label +from albow.controls import Button, Label, Widget from albow.layout import Column from albow.palette_view import PaletteView @@ -41,10 +42,26 @@ self.info.append(colstr) +class StateWidget(Widget): + + def __init__(self, state): + Widget.__init__(self, Rect(0, 0, 800, 600)) + self.state = state + + def draw(self, surface): + self.state.draw(surface) + + class GameScreen(Screen): def __init__(self, shell): Screen.__init__(self, shell) self.shell = shell + + # TODO: Randomly plonk the state here for now + self.state = initial_state() + self.state_widget = StateWidget(self.state) + self.add(self.state_widget) + StartButton = Button('Main Menu', action = self.main_menu) QuitButton = Button('Quit', action = shell.quit) AddItemButton = Button('Add item', action = self.add_item) @@ -56,11 +73,10 @@ AddItemButton, ], align='l', spacing=20) self.add_centered(menu) + self.inventory = InventoryView() self.inventory.bottomleft = self.bottomleft self.add(self.inventory) - # TODO: Randomly plonk the state here for now - self.state = initial_state() def main_menu(self): print 'Returning to menu'