本文整理汇总了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
示例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
示例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
示例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