本文整理汇总了Python中state.State.push_screen方法的典型用法代码示例。如果您正苦于以下问题:Python State.push_screen方法的具体用法?Python State.push_screen怎么用?Python State.push_screen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类state.State
的用法示例。
在下文中一共展示了State.push_screen方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import push_screen [as 别名]
def setUp(self):
pygame.mixer.init()
self.player = PlayerSprite()
self.invScreen = InventoryScreen(self.player)
self.invScreen.lines = ['Test1', 'Test2']
State.screens = []
State.push_screen(self.invScreen)
示例2: handle_keyboard
# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import push_screen [as 别名]
def handle_keyboard(self, events):
'''
Function to handle the keyboard events and act accordingly
@param events - The list of events from the game
'''
self.keyboard_input = {
key: (new_val, new_val)
for key, (old_val, new_val)
in self.keyboard_input.items()
}
for event in events:
if not hasattr(event, 'key'):
continue
if event.type == KEYDOWN:
if event.key == K_p:
State.push_screen(PauseScreen(self.player, self.tileMap))
if event.key == K_i:
State.push_screen(InventoryScreen(self.player))
if event.key in self.keyboard_input:
(old_val, new_val) = self.keyboard_input[event.key]
self.keyboard_input[event.key] = (new_val, event.type)
示例3: update
# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import push_screen [as 别名]
def update(self, events):
'''
Updates the screen when an event happens
@param - list of game events
'''
for event in events:
if not hasattr(event, 'key'):
continue
if event.type == KEYDOWN:
if event.key == K_RETURN:
if self.currLine == GameMenuScreenLine.NewGame:
gui = EnterSaveNameGUI()
save_name = gui.saveName
if len(save_name) <= 0:
continue
load(NEW_GAME_DIR)
State.save_name = save_name
State.push_screen(gameScreen.GameScreen(CURRENT_GAME_DIR))
elif self.currLine == GameMenuScreenLine.LoadGame:
State.push_screen(loadGameScreen.LoadGameScreen())
elif self.currLine == GameMenuScreenLine.Exit:
sys.exit(0)
else:
super(GameMenuScreen, self).interact(event)
示例4: update
# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import push_screen [as 别名]
def update(self, events):
'''
Updates the screen when an event happens
@param - list of game events
'''
for event in events:
if not hasattr(event, 'key'):
continue
if event.type == KEYDOWN:
if event.key == K_p:
State.pop_screen()
elif event.key == K_RETURN:
self.sounds['select'].play()
if self.currLine == PauseScreenLines.Resume:
State.pop_screen()
if self.currLine == PauseScreenLines.Save:
self.tileMap.save(self.player)
save(USER_SAVES_DIR + State.save_name)
elif self.currLine == PauseScreenLines.Quit:
State.pop_screen()
State.pop_screen()
elif event.key == K_i:
State.push_screen(InventoryScreen(self.player))
else:
super(PauseScreen, self).interact(event)
示例5: victory
# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import push_screen [as 别名]
def victory(self):
'''
Once the victory condition has been met, it will push the victory screen to state
'''
State.push_screen(
VictoryScreen(
TileMap.width*TileMap.BLOCK_SIZE[0],
TileMap.height*TileMap.BLOCK_SIZE[1]
)
)
示例6: update
# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import push_screen [as 别名]
def update(self, events):
'''
Updates everything in the game
This includes:
- checking to see if the final condition has been met
- handling keybour events
- Checking kill count
- Having each enemy call their act functions
- Checking collisions
- Updating each tile
- Checking the health of the player
'''
if State.boss_ready:
self.gate_group.empty()
self.tileMap.tile.gates = []
self.handle_keyboard(events)
self.player.handle_input(self.keyboard_input, self.tileMap.tile, self.bullet_group)
self.player.check_count()
for enemy in self.enemy_group:
enemy.act(self.tileMap.tile)
for shooter in self.shooters:
(px, py) = self.player.coords
if shooter.shouldShoot(px, py):
shooter.shoot(shooter, self.enemy_bullet_group)
self.check_collisions()
if(self.tileMap.update(self.player, self.enemy_group)):
self.bullet_group.update()
self.enemy_bullet_group.update()
self.player_group.update()
self.enemy_group.update()
else:
self.reset_sprite_groups()
if self.player.health <= 0:
self.player.lives -= 1
if self.player.lives <= 0:
State.push_screen(
GameOverScreen(
TileMap.width*TileMap.BLOCK_SIZE[0],
TileMap.height*TileMap.BLOCK_SIZE[1]
)
)
else:
self.tileMap.set_tile(self.player, 0, 0)
self.player.health = self.player.std_health
self.player.coords = (5, 5)
self.reset_sprite_groups()
示例7: update
# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import push_screen [as 别名]
def update(self, events):
'''
Updates the screen when an event happens
@param - list of game events
'''
for event in events:
if not hasattr(event, 'key'):
continue
if event.type == KEYDOWN:
if event.key == K_RETURN:
if self.currLine == VictoryScreenLine.Menu:
State.push_screen(gameMenuScreen.GameMenuScreen())
elif self.currLine == VictoryScreenLine.Exit:
sys.exit(0)
else:
super(VictoryScreen, self).interact(event)
示例8: update
# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import push_screen [as 别名]
def update(self, events):
'''
Updates the screen when an event happens
@param - list of game events
'''
for event in events:
if not hasattr(event, 'key'):
continue
if event.type == KEYDOWN:
if event.key == K_RETURN:
if self.currLine == LoadGameScreenLine.ReturnToMainMenu:
State.pop_screen()
continue
save_name = self.lines[self.currLine]
load(USER_SAVES_DIR + save_name)
State.save_name = save_name
State.pop_screen()
State.push_screen(gameScreen.GameScreen(CURRENT_GAME_DIR))
else:
super(LoadGameScreen, self).interact(event)