当前位置: 首页>>代码示例>>Python>>正文


Python settings.Settings方法代码示例

本文整理汇总了Python中settings.Settings方法的典型用法代码示例。如果您正苦于以下问题:Python settings.Settings方法的具体用法?Python settings.Settings怎么用?Python settings.Settings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在settings的用法示例。


在下文中一共展示了settings.Settings方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_events

# 需要导入模块: import settings [as 别名]
# 或者: from settings import Settings [as 别名]
def check_events(ai_settings: Settings, stats: GameStats, game_items: GameItems):
    """Respond to keypresses and mouse events."""

    # Watch for keyboard and mouse events.
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            quit_game(stats)

        elif event.type == pygame.KEYDOWN:
            check_keydown_events(event, ai_settings, stats, game_items)

        elif event.type == pygame.KEYUP:
            check_keyup_events(event, game_items.ship)

        elif event.type == pygame.MOUSEBUTTONDOWN:
            check_mousedown_events(ai_settings, stats, game_items) 
开发者ID:goswami-rahul,项目名称:alien-invasion-game,代码行数:18,代码来源:game_functions.py

示例2: check_keydown_events

# 需要导入模块: import settings [as 别名]
# 或者: from settings import Settings [as 别名]
def check_keydown_events(event: EventType, ai_settings: Settings
                         , stats: GameStats, game_items: GameItems):
    """Respond when key is being pressed."""
    if event.key == pygame.K_RIGHT:
        # Move ship to the right.
        game_items.ship.moving_right = True

    elif event.key == pygame.K_LEFT:
        # Move ship to the left.
        game_items.ship.moving_left = True

    elif event.key == pygame.K_SPACE:
        fire_bullet(ai_settings, game_items)

    elif event.key == pygame.K_q:
        quit_game(stats)

    elif event.key == pygame.K_RETURN:  # ENTER key
        start_new_game(ai_settings, stats, game_items) 
开发者ID:goswami-rahul,项目名称:alien-invasion-game,代码行数:21,代码来源:game_functions.py

示例3: check_bullet_alien_collision

# 需要导入模块: import settings [as 别名]
# 或者: from settings import Settings [as 别名]
def check_bullet_alien_collision(ai_settings: Settings, stats: GameStats, game_items: GameItems):
    """Update the game when a bullet hits an alien(s)."""

    # Get rid of bullet and aliens that have collided.
    collision = pygame.sprite.groupcollide(game_items.bullets, game_items.aliens, True, True)
    if collision:
        for aliens_hit_list in collision.values():
            stats.score += ai_settings.alien_points * len(aliens_hit_list)
            game_items.sb.prep_score()
        check_high_score(stats, game_items)

    # Create new fleet after fleet is empty.
    if len(game_items.aliens.sprites()) == 0:
        game_items.bullets.empty()
        ai_settings.increase_speed()
        stats.level += 1
        game_items.sb.prep_level()
        create_fleet(ai_settings, game_items) 
开发者ID:goswami-rahul,项目名称:alien-invasion-game,代码行数:20,代码来源:game_functions.py

示例4: ship_hit

# 需要导入模块: import settings [as 别名]
# 或者: from settings import Settings [as 别名]
def ship_hit(ai_settings: Settings, stats: GameStats, game_items: GameItems):
    """Respond to ship being hit by an alien."""

    if stats.ships_left > 0:

        # Decrement ships left.
        stats.ships_left -= 1

        # Update scorecard.
        game_items.sb.prep_ships()

        # Empty bullets and aliens.
        game_items.bullets.empty()
        game_items.aliens.empty()

        # Create a new fleet and center the ship.
        create_fleet(ai_settings, game_items)
        game_items.ship.center_ship()

        # Pause.
        time.sleep(0.5)

    else:
        stats.game_active = False
        pygame.mouse.set_visible(True) 
开发者ID:goswami-rahul,项目名称:alien-invasion-game,代码行数:27,代码来源:game_functions.py

示例5: __init__

# 需要导入模块: import settings [as 别名]
# 或者: from settings import Settings [as 别名]
def __init__(self, ai_settings: Settings, stats: GameStats, screen: pygame.SurfaceType):

        self.screen = screen
        self.screen_rect = screen.get_rect()
        self.ai_settings = ai_settings
        self.stats = stats
        self.score_ship_size = self.ai_settings.score_ship_size  # size of ship in the scoreboard.
        self.dur_highscore_msg = 3000        # duration of highscore msg = 3 sec

        # Font settings.
        font_name = 'fonts/PoiretOne.ttf'       # try changing the font
        self.font_color = self.ai_settings.score_font_color
        self.font = pygame.font.Font(font_name, self.ai_settings.score_font_size)

        # Prepare the initial score image.
        self.prep_images() 
开发者ID:goswami-rahul,项目名称:alien-invasion-game,代码行数:18,代码来源:scorecard.py

示例6: __init__

# 需要导入模块: import settings [as 别名]
# 或者: from settings import Settings [as 别名]
def __init__(self, ai_settings: Settings):

        self.ai_settings = ai_settings
        self.ships_left = self.ai_settings.ship_left
        self.score = 0
        self.level = 1
        self.time_to_blit = None
        self.broke_highscore = False
        self.game_active = False

        filename = 'save/highscore.txt'
        try:
            with open(filename, 'r') as f:
                self.prev_high_score = int(f.read())
        except FileNotFoundError:
            print('No save file found.')
            print("Creating new save file 'save/highscore.txt'")
            if not os.path.exists('save'):
                os.makedirs('save')
            with open('save/highscore.txt', 'w+') as f:
                f.write('0')
            self.prev_high_score = 0

        self.high_score = self.prev_high_score
        self.time_passed = 0.0 
开发者ID:goswami-rahul,项目名称:alien-invasion-game,代码行数:27,代码来源:game_stats.py

示例7: __init__

# 需要导入模块: import settings [as 别名]
# 或者: from settings import Settings [as 别名]
def __init__(self, reader, writer, token):
        super().__init__(Platform.HumbleBundle, __version__, reader, writer, token)
        self._api = AuthorizedHumbleAPI()
        self._download_resolver = HumbleDownloadResolver()
        self._app_finder = AppFinder()
        self._settings = Settings()
        self._library_resolver = None
        self._subscription_months: List[ChoiceMonth] = []

        self._owned_games: t.Dict[str, HumbleGame] = {}
        self._trove_games: t.Dict[str, TroveGame] = {}
        self._choice_games: t.Dict[str, ChoiceGame] = {}

        self._local_games = {}
        self._cached_game_states = {}

        self._getting_owned_games = asyncio.Lock()
        self._owned_check: asyncio.Task = asyncio.create_task(asyncio.sleep(8))
        self._statuses_check: asyncio.Task = asyncio.create_task(asyncio.sleep(4))
        self._installed_check: asyncio.Task = asyncio.create_task(asyncio.sleep(4))

        self._rescan_needed = True
        self._under_installation = set() 
开发者ID:UncleGoogle,项目名称:galaxy-integration-humblebundle,代码行数:25,代码来源:plugin.py

示例8: on_post_save

# 需要导入模块: import settings [as 别名]
# 或者: from settings import Settings [as 别名]
def on_post_save(self, view):
        settings = Settings()
        self.view = view
        self.run_kill = settings.get('kill_before_save_tasks', False)
        self.run_tasks(settings.get("tasks_on_save", {}))
        self.run_tasks(settings.get("silent_tasks_on_save", {}), silent=True)

        self.view.run_command("gulp_update_status_bar") 
开发者ID:nicosantangelo,项目名称:sublime-gulp,代码行数:10,代码来源:event_task.py

示例9: test_settings_test_config

# 需要导入模块: import settings [as 别名]
# 或者: from settings import Settings [as 别名]
def test_settings_test_config():
    settings = Settings(TEST_CONFIG_PATH)
    assert settings

    assert settings.setting("server_one", "username")
    assert len(settings.servers()) 
开发者ID:th3-z,项目名称:kf2-magicked-admin,代码行数:8,代码来源:test_settings.py

示例10: test_settings_bad_config

# 需要导入模块: import settings [as 别名]
# 或者: from settings import Settings [as 别名]
def test_settings_bad_config():
    with pytest.raises(IOError):
        Settings(BAD_CONFIG_PATH) 
开发者ID:th3-z,项目名称:kf2-magicked-admin,代码行数:5,代码来源:test_settings.py

示例11: test_settings_skip_config

# 需要导入模块: import settings [as 别名]
# 或者: from settings import Settings [as 别名]
def test_settings_skip_config():
    try:
        remove(SKIP_CONFIG_PATH)
    except Exception:
        pass

    with pytest.raises(SystemExit):
        Settings(SKIP_CONFIG_PATH, skip_setup=True)
    assert exists(SKIP_CONFIG_PATH)

    config = configparser.ConfigParser()
    config.read(SKIP_CONFIG_PATH)

    remove(SKIP_CONFIG_PATH) 
开发者ID:th3-z,项目名称:kf2-magicked-admin,代码行数:16,代码来源:test_settings.py

示例12: __init__

# 需要导入模块: import settings [as 别名]
# 或者: from settings import Settings [as 别名]
def __init__(self):
        phone_home()
        signal.signal(signal.SIGINT, self.terminate)
        self.stop_list = []
        self.sigint_count = 0
        self.settings = Settings(
            CONFIG_PATH,
            skip_setup=args.skip_setup
        ) 
开发者ID:th3-z,项目名称:kf2-magicked-admin,代码行数:11,代码来源:magicked_admin.py

示例13: reconfigure

# 需要导入模块: import settings [as 别名]
# 或者: from settings import Settings [as 别名]
def reconfigure(self):
        self.settings = Settings(
            CONFIG_PATH,
            skip_setup=args.skip_setup,
            reconfigure=True
        ) 
开发者ID:th3-z,项目名称:kf2-magicked-admin,代码行数:8,代码来源:magicked_admin.py

示例14: __init__

# 需要导入模块: import settings [as 别名]
# 或者: from settings import Settings [as 别名]
def __init__(self, id, arg = None):
        self.id = id
        print("MUSIC!!!")
        if Settings["ENABLE_JNTM"]:
            from pygame import mixer
            self.mixer = mixer
            self.mixer.init()
            self.mixer.music.load(os.path.join(os.getcwd(), "code/jntm.mp3"))
        else:
            self.mixer = None 
开发者ID:chbpku,项目名称:osmo.sessdsa,代码行数:12,代码来源:cxk.py

示例15: main

# 需要导入模块: import settings [as 别名]
# 或者: from settings import Settings [as 别名]
def main():
    parser = argparse.ArgumentParser(description='Backup tool for ceph')
    default_cephbackup_cfg = '/etc/cephbackup/cephbackup.conf'
    parser.add_argument('-c', '--conf', help="path to the configuration file (default: {})".format(default_cephbackup_cfg), type=str, default=default_cephbackup_cfg)
    args = parser.parse_args()
    settings = Settings(args.conf)
    settings.start_backup() 
开发者ID:teralytics,项目名称:ceph-backup,代码行数:9,代码来源:__main__.py


注:本文中的settings.Settings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。