示例#1
0
class Game(Application):

    def __init__(self):
        Application.__init__(self)

        self.last_ticks = time.time()
        self.framerate = 1000 / 60.

        self._screen = NoScreen()

    @property
    def screen(self):
        return self._screen

    @screen.setter
    def screen(self, screen):
        self._screen.hide()
        self._screen = screen
        self._screen.show()

    def update(self):
        delay(self.framerate)
        delta_time = self.calculate_delta_time()
        self.screen.update(delta_time)

    def calculate_delta_time(self):
        ticks = time.time()
        delta_time = ticks - self.last_ticks
        self.last_ticks = ticks
        return delta_time
示例#2
0
    def __init__(self):
        Application.__init__(self)

        self.last_ticks = time.time()
        self.framerate = 1000 / 60.

        self._screen = NoScreen()