コード例 #1
0
ファイル: main.py プロジェクト: gentimouton/pang
def main():
    pg.init()
    pg.display.set_caption('Pang')
    pview.set_mode((800, 600))
    clock = pg.time.Clock()
    sm.init()

    while True:
        ms = clock.tick(settings.FPS)  # throttle

        outcome = controller.poll()  # get player input
        if outcome == OUT_QUIT:
            break
        elif outcome == OUT_FSCR:
            pview.toggle_fullscreen()

        outcome = sm.scene_manager.tick(ms)  # update scene
        if outcome == OUT_QUIT:
            break
コード例 #2
0
ファイル: main.py プロジェクト: gentimouton/sokobalt
def main():

    # configure the logger before anything else happens
    logging.config.fileConfig('logging.conf')

    # The game logger is configured when the config module is imported.
    log = logging.getLogger('game')
    log.info('Main started')

    # load levels
    levels = load_level_set(LEVELS_FILENAME, LEVELS_MAXSIZE)  # list

    pg.init()
    pg.display.set_caption('Sokobalt')
    pview.set_mode(BASE_RES)
    clock = pg.time.Clock()
    scenes = {SCN_MENU: MenuScene(levels), SCN_GAME: GameScene(levels)}
    cur_scene = scenes[SCN_MENU]

    while True:
        ms = clock.tick(FPS)  # throttle

        # poll controls
        outcome = controller.poll()  # get player input
        if outcome == OUT_QUIT:
            break
        elif outcome == OUT_FSCR:
            pview.toggle_fullscreen()
            cur_scene.redraw()

        # tick scene
        next_scene_id, kwargs = cur_scene.tick(ms)
        if next_scene_id == SCN_QUIT:  # quit via dummy scene constant
            break
        elif next_scene_id is not None:  # change scene
            cur_scene.pause()
            cur_scene = scenes[next_scene_id]
            cur_scene.resume(**kwargs)
コード例 #3
0
ファイル: game_scene.py プロジェクト: gentimouton/sokobalt
    def redraw(self):
        # TODO: recompute/redraw bg
        # self._draw()
        pass


if __name__ == "__main__":
    from constants import OUT_QUIT, OUT_FSCR
    from settings import LEVELS_FILENAME, LEVELS_MAXSIZE
    from level import load_level_set

    pg.init()
    pview.set_mode(BASE_RES)
    clock = pg.time.Clock()
    levels = load_level_set(LEVELS_FILENAME, LEVELS_MAXSIZE)  # list
    scene = GameScene(levels)
    while True:
        ms = clock.tick(30)
        outcome = controller.poll()  # get player input
        if outcome == OUT_QUIT:
            break
        elif outcome == OUT_FSCR:
            pview.toggle_fullscreen()
            scene.redraw()

        next_scene_id, kwargs = scene.tick(ms)
        if next_scene_id == SCN_GAME:  # level completed, switch to game scene
            scene.resume(**kwargs)
        pg.display.set_caption('game scene -- %.1f fps' % clock.get_fps())