예제 #1
0
def main():
    if len(sys.argv) > 1:
        config_file_name = sys.argv[1]
    else:
        config_file_name = 'config.json'

    with open(config_file_name, 'r') as f:
        config = json.load(f)

    pygame.init()

    random.seed()

    # Need to hide mouse pointer here since the MediaPlayer class
    # might be used to render on a surface instead of a display
    pygame.mouse.set_visible(False)

    screen = Screen(width=config['display']['width'],
                    height=config['display']['height'],
                    bg_color=pygame.Color('black'),
                    fullscreen=config['display']['fullscreen'])

    screen_surface = screen.surface
    play_again = True

    while play_again:
        player = MediaPlayer(surface=screen_surface,
                             config=config,
                             surface_is_display=True)

        play_again = player.run()

    pygame.quit()
예제 #2
0
def main():
    with open('media-config.json', 'r') as f:
        media_config = json.load(f)

    with open('activity-config.json', 'r') as f:
        activity_config = json.load(f)

    # Small buffer size to prevent delays when playing sounds
    pygame.mixer.init(buffer=512)
    pygame.init()

    random.seed()

    # Need to hide mouse pointer here since the other classes
    # might be used to render on a surface instead of a display
    pygame.mouse.set_visible(False)

    screen = Screen(
        width=activity_config['display']['width'],
        height=activity_config['display']['height'],
        bg_color=pygame.Color(activity_config['board']['bg_color']),
        fullscreen=activity_config['display']['fullscreen'])

    screen_surface = screen.surface
    play_again = True

    while True:
        while play_again:
            player = MediaPlayer(
                surface=screen_surface,
                config=media_config,
                surface_is_display=True)

            play_again = player.run()

        play_again = True

        while play_again:
            board = ActivityBoard(
                surface=screen_surface,
                config=activity_config,
                start_hidden=True,
                surface_is_display=True)

            play_again = board.run()

        play_again = True