本文整理汇总了Python中hud.Hud.update_prop方法的典型用法代码示例。如果您正苦于以下问题:Python Hud.update_prop方法的具体用法?Python Hud.update_prop怎么用?Python Hud.update_prop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hud.Hud
的用法示例。
在下文中一共展示了Hud.update_prop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GameScreen
# 需要导入模块: from hud import Hud [as 别名]
# 或者: from hud.Hud import update_prop [as 别名]
class GameScreen(Events):
"""docstring for GameScreen"""
def __init__(self, window):
super(GameScreen, self).__init__()
self.window = window
self.camera = Camera(window)
self.player = player.Player()
self.proj_viewer = ProjectileViewer(self.send_center)
self.controls = {}
self.controls_old = {}
self.map = Map('blank')
#self.player.spawn(100, 100)
self.time = 0
self.moves = moves(1024)
self.index = [0]
self.head = [0]
#other players
self.players = {}
self.specs = {}
#crosshair
self.cross = CrossHair()
self.isSpec = True
self.hud = Hud()
self.gs_view = GameStateViewer(self.players, self.hud.update_prop,
self.hud.set_score)
def update(self, dt):
dt = int(dt * 1000000) / 1000000.
if self.controls['esc'] and not self.controls_old['esc']:
self.send_message('menu_transition_+', (GameMenu, self.isSpec))
if self.controls['rdy'] and not self.controls_old['rdy']:
if not self.isSpec:
self.ready_up()
if self.controls['chat'] and not self.controls_old['chat']:
self.send_message('menu_transition_+',
(ChatScreen, self.window))
self.update_keys()
self.on_update(dt)
def update_physics(self, dt, state=False, input=False):
playergen = (player.rect for player in self.players.itervalues())
mapgen = (rect for rect in self.map.quad_tree.retrieve([],
self.player.rect))
rectgen = chain(playergen, mapgen)
self.player.update(dt, rectgen, state, input)
return self.player.state
def update_state_only(self, state):
self.player.state.update(0, state)
def update_keys(self):
for key_, value in self.controls.items():
self.controls_old[key_] = value
def from_server(self, data):
typ, data = data
if typ == proto.playerUpdate:
ind, time, s_state, inpt, weaponinfo = data
smove = move(time, inpt, s_state)
if ind == self.player.id:
correct_client(self.update_physics, smove, self.moves,
self.head, self.index[0],
self.update_state_only)
self.player.weapons.from_server(weaponinfo)
else:
#try:
self.players[ind].client_update(s_state)
self.players[ind].input = inpt
#except KeyError:
# pass
elif typ == proto.projectile:
self.proj_viewer.process_proj(data)
elif typ == proto.newPlayer:
gs, data = data
if gs == proto.goesSpec:
ind, name, colstring = data
new = player.Player()
new.name = name
new.id = ind
new.set_color(colstring)
self.specs[ind] = new
#if there are existing players on the server
elif gs == proto.wantsJoin:
ind, name, state, time, colstring = data
new = player.Player()
new.name = name
new.state = state
new.time = time
new.id = ind
new.set_color(colstring)
new.rect.update_color(new.color)
self.players[ind] = new
print 'new player: %s' % name
self.gs_view.to_team(ind)
elif typ == proto.disconnect:
ind = data
if ind in self.players:
#.........这里部分代码省略.........
示例2: GameScreen
# 需要导入模块: from hud import Hud [as 别名]
# 或者: from hud.Hud import update_prop [as 别名]
class GameScreen(Events):
"""docstring for GameScreen"""
def __init__(self, window, input_handler):
super(GameScreen, self).__init__()
self.window = window
self.input_handler = input_handler
self.camera = Camera(window)
self.render = Render(self.camera, self.window)
sc_batch = self.render.scene_batch
st_batch = self.render.static_batch
self.player = player.Player(renderhook=self.render.playerhook)
self.proj_viewer = ProjectileViewer(
self.send_center, batch=sc_batch, scale=self.render.scale,
rndhook=self.render.attack)
self.controls = {}
self.controls_old = {}
self.map = Map('blank')
#self.player.spawn(100, 100)
self.time = 0
self.moves = moves(1024)
self.index = [0]
self.head = [0]
#other players
self.players = {}
self.specs = {}
#crosshair
self.cross = CrossHair(batch=st_batch)
self.isSpec = 0.5
self.hud = Hud(batch=st_batch, window=self.window)
self.gs_view = GameStateViewer(self.players, self.hud.update_prop,
self.hud.set_score)
self.frozen = False
self.rest_time = 0
def update(self, dt):
dt = int(dt * 1000000.) / 1000000.
if self.controls['esc'] and not self.controls_old['esc']:
self.send_message('menu_transition_+', (GameMenu, self.isSpec))
if self.controls['rdy'] and not self.controls_old['rdy']:
if not self.isSpec:
self.ready_up()
self.render.move_ahead()
if self.controls['chat'] and not self.controls_old['chat']:
self.send_message('menu_transition_+',
(ChatScreen, None))
self.update_keys()
for plr in self.players.itervalues():
mapgen = [rect for rect in self.map.quad_tree.retrieve([],
plr.rect)]
plr.predict(dt, mapgen)
self.on_update(dt)
def update_physics(self, dt, state=False, input=False):
self.player.update(dt, self.get_rect(), state, input)
return self.player.state.copy()
def update_state_only(self, state):
self.player.state.update_hp(state)
def update_keys(self):
for key_, value in self.controls.items():
self.controls_old[key_] = value
def from_server(self, data):
typ, data = data
if typ == proto.playerUpdate:
ind, time, s_state, inpt, weaponinfo = data
smove = move(time, inpt, s_state)
if ind == self.player.id:
correct_client(self.update_physics, smove, self.moves,
self.head, self.index[0],
self.update_state_only)
self.player.weapons.from_server(weaponinfo)
else:
self.players[ind].client_update(s_state)
self.players[ind].input = inpt
if ind == self.isSpec:
self.camera.mpos_from_aim(vec2(inpt.mx, inpt.my))
self.players[ind].weapons.from_server(weaponinfo)
self.render.weapon_check(ind, weaponinfo)
elif typ == proto.projectile:
self.proj_viewer.process_proj(data)
elif typ == proto.newPlayer:
gs, data = data
if gs == proto.goesSpec:
ind, name, colstring = data
new = player.Player(renderhook=self.render.playerhook, id=ind)
new.name = name
new.id = ind
new.set_color(colstring)
new.rect.update_color(new.color)
self.specs[ind] = new
#if there are existing players on the server
elif gs == proto.wantsJoin:
ind, name, state, time, colstring = data
new = player.Player(renderhook=self.render.playerhook, id=ind)
new.name = name
#.........这里部分代码省略.........