本文整理汇总了Python中hud.Hud.game_tick方法的典型用法代码示例。如果您正苦于以下问题:Python Hud.game_tick方法的具体用法?Python Hud.game_tick怎么用?Python Hud.game_tick使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hud.Hud
的用法示例。
在下文中一共展示了Hud.game_tick方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: from hud import Hud [as 别名]
# 或者: from hud.Hud import game_tick [as 别名]
class MonorailGame:
STATE_INTRO, STATE_BEGIN, STATE_GAME, STATE_MENU, STATE_QUIT, STATE_STATS, STATE_TOTAL,\
STATE_DONE = range( 8 )
MOUSE_TIMEOUT = 25 * 3
def __init__( self, game_data ):
self.restart( game_data )
self.music_man = MusicManager()
# preload clock sounds and big explosion graphic
resman.get("game.clock_sound")
resman.get("game.clockring_sound")
resman.get("game.explosion_sprite")
def restart( self, game_data ):
"""Start a new game with the current game_data"""
self.game_data = game_data
self.state = MonorailGame.STATE_INTRO
self.scenario = self.game_data.get_quest().create_scenario(self.game_data.skill_level.value)
self.playfield = self.scenario.playfield
self.controller = ctrl.GroundControl( self.playfield )
self.init_goldcars()
self.hud = Hud( self.scenario, self.controller, self.game_data )
self.hud.start_intro_screen()
self.begin_timeout = 25 * 3
self.ingame_menu = None
self.gui_state = GuiState()
self.mouse_timeout = MonorailGame.MOUSE_TIMEOUT
self.is_paused = False
def init_goldcars( self ):
goldcar_names = []
controllers = []
for name, controller in self.game_data.goldcars:
goldcar_names.append( name )
controllers.append( controller )
for iq in self.game_data.get_quest().get_opponent_iqs():
goldcar_names.append( "" )
controllers.append( ctrl.AiController( None, iq ) )
self.playfield.add_goldcars( goldcar_names )
self.controller.add_controllers( controllers )
def do_tick( self, indev ):
if self.ingame_menu is None and not self.is_paused:
if self.game_data.is_single_player() or \
self.game_data.is_single_random():
SingleSwitch.feed_keys( indev )
# in singleplayer, all joystick buttons are keypress
for joy in indev.joys:
if joy.any_went_down():
indev.key.feed_down( K_SPACE )
if joy.any_went_up():
indev.key.feed_up( K_SPACE )
if self.state == MonorailGame.STATE_INTRO:
if self.hud.is_ready(): # or self.game_data.is_single_player():
self.hud.end_info()
self.state = MonorailGame.STATE_BEGIN
self.music_man.play()
elif self.state == MonorailGame.STATE_BEGIN:
if self.begin_timeout % 50 == 0:
random_spawn = not self.game_data.is_single_player();
spawns_left = self.playfield.spawn_next_goldcar( random_spawn )
if spawns_left:
self.begin_timeout += 50
self.controller.game_tick( indev )
self.playfield.game_tick()
# Start right away in single player
if self.game_data.is_single_player():
self.scenario.game_tick()
self.begin_timeout -= 1
if self.begin_timeout <= 0:
self.state = MonorailGame.STATE_GAME
if indev.mouse.has_moved():
self.mouse_timeout = MonorailGame.MOUSE_TIMEOUT
else:
self.mouse_timeout -= 1
elif self.state == MonorailGame.STATE_GAME:
self.controller.game_tick( indev )
self.playfield.game_tick()
self.scenario.game_tick()
if self.scenario.is_finished():
#.........这里部分代码省略.........