Пример #1
0
    def __init__(self, eventLoop, size=(800,600), targetFrameRate=None, resizable=True):
        pygame.display.init()
        pygame.key.set_repeat(500, 30)

        self.display = pygame.display
        self.resizable = resizable
        Viewport.__init__(self, eventLoop, size)

        # Add event handlers for all the pygame events we can find
        for i in xrange(100):
            name = pygame.event.event_name(i)
            if name != "Unknown":
                Event.attach(self, 'on' + name)

        self.init()
        self.frameTimer = None
        self.setTargetFrameRate(targetFrameRate)
Пример #2
0
    def region(self, rect, renderLink='after'):
        # Note that we use Viewport.region(), since PygameViewport.region()
        # bothers with creating a subsurface, which we don't need.
        sub = Viewport.region(self, rect, renderLink)

        # Disable the root viewport's frame setup and finishing code,
        # but leave configureOpenGL running in each viewport.
        sub.onSetupFrame.replace(sub.configureOpenGL)
        sub.onFinishFrame.empty()
        return sub
Пример #3
0
    def region(self, *args, **kw):
        """Return a class that represents a rectangular subsection of this viewport.
           In addition to what Viewport.region() does, this sets our screen to be
           a subsurface of the original screen.
           """
        sub = Viewport.region(*args, **kw)
        sub.screen = self.secreen.subsurface(sub.rect)

        # Disable flipping the surface in our subviewport
        sub.onFinishFrame.empty()
        return sub