예제 #1
0
    def setup(self):
        self.display = Display()
        self.sound = Sound()
        self.gamestate = Gamestate()

        # given that there is some iteraction between the game view
        # and the game logic, separate the setup for both
        self.display.setup()
        self.sound.setup()
        self.gamestate.setup()
예제 #2
0
    def setup(self):
        self.display = Display()
        self.sound = Sound()
        self.gamestate = Gamestate()

        # given that there is some iteraction between the game view
        # and the game logic, separate the setup for both
        self.display.setup()
        self.sound.setup()
        self.gamestate.setup()
예제 #3
0
class Gameloop(object):
    '''
    This class is used by the binary 'bin/flappy-judoka'.

    It ticks the time, updates the game logic, and draws a new frame.
    '''

    # the maximum fps the game will be running at
    FRAMES_PER_SECOND = 60

    def __init__(self):
        self.clock = pygame.time.Clock()

        self.setup()

    def setup(self):
        self.display = Display()
        self.sound = Sound()
        self.gamestate = Gamestate()

        # given that there is some iteraction between the game view
        # and the game logic, separate the setup for both
        self.display.setup()
        self.sound.setup()
        self.gamestate.setup()

    def run(self):
        debugger('Gameloop: run: Starting gameloop')

        while self.gamestate.is_running:
            # get the elapsed time since last tick and cap the fps
            delta_t_ms = self.clock.tick(self.FRAMES_PER_SECOND)
            delta_t_sec = delta_t_ms / 1000.0
            fps = self.clock.get_fps()

            drawables = self.gamestate.update(delta_t_sec)
            self.display.update(drawables, fps)

        debugger('Gameloop: run: Exiting gameloop')
예제 #4
0
class Gameloop(object):
    '''
    This class is used by the binary 'bin/flappy-judoka'.

    It ticks the time, updates the game logic, and draws a new frame.
    '''

    # the maximum fps the game will be running at
    FRAMES_PER_SECOND = 60

    def __init__(self):
        self.clock = pygame.time.Clock()

        self.setup()

    def setup(self):
        self.display = Display()
        self.sound = Sound()
        self.gamestate = Gamestate()

        # given that there is some iteraction between the game view
        # and the game logic, separate the setup for both
        self.display.setup()
        self.sound.setup()
        self.gamestate.setup()

    def run(self):
        debugger("Gameloop: run: Starting gameloop")

        while self.gamestate.is_running:
            # get the elapsed time since last tick and cap the fps
            delta_t_ms = self.clock.tick(self.FRAMES_PER_SECOND)
            delta_t_sec = delta_t_ms / 1000.0
            fps = self.clock.get_fps()

            drawables = self.gamestate.update(delta_t_sec)
            self.display.update(drawables, fps)

        debugger("Gameloop: run: Exiting gameloop")