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


Python State.handle_event方法代码示例

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


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

示例1: handle_event

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import handle_event [as 别名]
 def handle_event(self, event):
     from game import Overworld
     State.handle_event(self, event)
     if event.type == pygame.KEYDOWN:
         old_cur_x_index, old_cur_y_index = Overworld.cur_x_index, Overworld.cur_y_index
         if event.key == pygame.K_UP:
             Overworld.cur_y_index -= 1
             self.refresh_screen = True
         elif event.key == pygame.K_DOWN:
             Overworld.cur_y_index += 1
             self.refresh_screen = True
         elif event.key == pygame.K_LEFT:
             Overworld.cur_x_index -= 1
             self.refresh_screen = True
         elif event.key == pygame.K_RIGHT:
             Overworld.cur_x_index += 1
             self.refresh_screen = True
         if self._level.isWall(Overworld.center_x_index(), Overworld.center_y_index()):
             Overworld.cur_x_index = old_cur_x_index
             Overworld.cur_y_index = old_cur_y_index
         elif self._level.isLadder(Overworld.center_x_index(), Overworld.center_y_index()):
             self._level = self._level.load_level(Overworld.center_x_index(), Overworld.center_y_index())
             self.refresh_screen = True
         elif self._level.isMonster(Overworld.center_x_index(), Overworld.center_y_index()):
             from game import set_state
             from battle_state import BattleState
             from battle import Skeleton
             new_state = BattleState(Skeleton())
             set_state(new_state)
             new_state.play_music()
     return
开发者ID:doug3230,项目名称:Slayer,代码行数:33,代码来源:level_state.py

示例2: handle_event

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import handle_event [as 别名]
 def handle_event(self, event):
     State.handle_event(self, event)
     if event.type == pygame.KEYDOWN:
         if event.key == pygame.K_DOWN:
             if self._current_choice < self._number_of_choices - 1:
                 self._current_choice += 1
                 self.refresh_screen = True
         elif event.key == pygame.K_UP:
             if self._current_choice > 0:
                 self._current_choice -= 1
                 self.refresh_screen = True
         elif event.key == pygame.K_RETURN:
             if self._current_choice == 0:
                 from level_state import LevelState
                 from game import set_state
                 state = LevelState("tower_entrance.txt")
                 set_state(state)
                 state.play_music()
     return
开发者ID:doug3230,项目名称:Slayer,代码行数:21,代码来源:title_state.py

示例3: handle_event

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import handle_event [as 别名]
 def handle_event(self, event):
     State.handle_event(self, event)
     if self.child_state:
         self.child_state.handle_event(event)
     return
开发者ID:doug3230,项目名称:Tetris-Clone,代码行数:7,代码来源:state_system.py

示例4: handle_event

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import handle_event [as 别名]
 def handle_event(self, event):
     State.handle_event(self, event)
     return
开发者ID:doug3230,项目名称:Slayer,代码行数:5,代码来源:battle_state.py


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