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


Python GameState.hero_fire方法代码示例

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


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

示例1: handle_input

# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import hero_fire [as 别名]
def handle_input(log, END_GAME = False):
    """
    Handles all external input,such as those  keyboard and mouse.
    """
    for event in pygame.event.get():

        keys = pygame.key.get_pressed()

        # Closing
        handle_quit(event)

        if keyboard.queue_prompt(event):
            game_state.next_wave()

        # Pausing game
        if keyboard.pause_prompt(keys):
            game_state.toggle_paused()   

        # Hero's movement
        hero_dir = keyboard.movement(keys)
        game_state.hero.change_direction(hero_dir)

        #END_GAME
        global game_state
        handle_quit(event, END_GAME)
        if keyboard.restart(event, END_GAME):
            if game_state.mode == "FIXED":
                new_choice = "DYNAMIC"
            else:
                new_choice = "FIXED"
            game_state = GameState(new_choice)
            log.refresh(new_choice)
            log.first_row()
            

        # Sound Adjustment
        if keyboard.music_prompt(keys):
            dj.switch_background_music()
        if keyboard.increase_prompt(keys):
            dj.increase_volume()
        if keyboard.decrease_prompt(keys):
            dj.decrease_volume()
        
        # Shoot Laser
        if keyboard.laser_prompt(keys):
            if game_state.hero.laser_equipped:
                game_state.hero.is_firing_laser = True
                game_state.hero.fire_time = time.clock()

        # Shoot Pew
        if keyboard.pew_prompt(keys):
            if game_state.hero.ok_to_shoot():
                game_state.hero_fire()
                dj.play_pew()
开发者ID:quantumgl,项目名称:AI-Pygame,代码行数:56,代码来源:game.py


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