view pyntnclick/widgets/game.py @ 602:1aac5a3b17e1 pyntnclick

Remove anything that has to do with focus (hopefully not breaking anything)
author Stefano Rivera <stefano@rivera.za.net>
date Sat, 11 Feb 2012 20:05:22 +0200
parents b7d8b89de71a
children
line wrap: on
line source

"""Display the game area."""

from pygame.rect import Rect

from pyntnclick.widgets.base import Widget
from pyntnclick.engine import FlipArrowsEvent


class GameWidget(Widget):
    def __init__(self, world, offset=(0, 0)):
        self.world = world
        rect = Rect(offset, world.get_size())
        super(GameWidget, self).__init__(rect)
        self.add_callback(FlipArrowsEvent, self.flip_arrows)

    def flip_arrows(self, ev, widget):
        self.world.level.flip_arrows()

    def draw(self, surface):
        self.world.update()
        self.world.draw(surface)

    def restart(self):
        self.world.restart()