本文整理汇总了Python中hud.Hud.set_counter方法的典型用法代码示例。如果您正苦于以下问题:Python Hud.set_counter方法的具体用法?Python Hud.set_counter怎么用?Python Hud.set_counter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hud.Hud
的用法示例。
在下文中一共展示了Hud.set_counter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: from hud import Hud [as 别名]
# 或者: from hud.Hud import set_counter [as 别名]
class Game (GameState):
def do_setup (self, level):
super (Game, self).do_setup ()
self.level = level
self.setup_panda ()
self.level.setup_entities (self.entities)
self.setup_input ()
self.setup_controllers ()
self.setup_hud ()
self.setup_logic ()
self.enter_transition ()
self.events.event ('panda-escape').connect (self.enter_menu)
self.events.event ('panda-p').connect (self.toggle_pause)
self.manager.enter_state (
GameMessage, message =
(('You have to kill %i pigeons in this level...\n' +
'Can you make it?') % self.total_pigeons))
def enter_transition (self):
self._transition_bg = ui.ImageEntity (entities = self.entities,
image = 'hud/red-bg.png')
self._transition_bg.alpha = 1.0
self._transition_bg.fade_out ()
def leave_transition (self, next_st = 'menu'):
self._transition_bg.fade_in ().add_next (task.run (lambda:
self.manager.leave_state (last_state = next_st)))
def enter_menu (self):
self.manager.enter_state ('menu-noload', None, 'ingame')
@weak_slot
def on_kill_pigeon (self):
self.hud.dec_counter ('pigeons', 1)
self.dead_pigeons += 1
if self.dead_pigeons >= self.total_pigeons:
self.win_game ()
@weak_slot
def on_kill_boy (self):
self.fail_game (random.choice (['You are dead!',
'Was it that hard to stay alive?',
"Your soul is burning in hell..."]))
@weak_slot
def on_finish_time (self):
self.fail_game (random.choice (['No more time for you!',
'Too slow man...',
'Hurry up the next time!']))
def win_game (self):
if self.manager.current == self:
self.manager.enter_state (
GameMessage,
'YOU WON!\n'
'This was a show-case level of an in-development game,\n'
'there is more to come in the future.',
'quit')
def fail_game (self, reason):
if self.manager.current == self:
msg = random.choice (['LOOOOOOOOSER', 'You lost!', 'What a pity!',
'Hey, no luck today!'])
self.manager.enter_state (GameMessage, reason + '\n' + msg, 'retry')
@weak_slot
def on_place_stick (self):
if self.player_ctl.can_place_stick:
self.num_sticks -= 1
if self.num_sticks == 0:
self.player_ctl.can_place_stick = False
self.hud.set_counter ('sticks', self.num_sticks)
def highlight_stick_task (self, timer):
pos = self.player_ctl.get_place_position (5)
best = self.player_ctl.laser.best_stick (pos)
if best != self._curr_best_stick:
if self._curr_best_stick:
self._curr_best_stick.unhighlight ()
if self.player_ctl.can_place_stick:
self._curr_best_stick = best
if best:
best.highlight ()
return task.running
def do_update (self, timer):
super (Game, self).do_update (timer)
@weak_slot
def on_shader_change (self, cfg):
if cfg.value:
self.glow_filter.enable (self.manager.panda)
else:
self.glow_filter.disable ()
#.........这里部分代码省略.........