本文整理汇总了Python中hud.Hud.display方法的典型用法代码示例。如果您正苦于以下问题:Python Hud.display方法的具体用法?Python Hud.display怎么用?Python Hud.display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hud.Hud
的用法示例。
在下文中一共展示了Hud.display方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Lienzo
# 需要导入模块: from hud import Hud [as 别名]
# 或者: from hud.Hud import display [as 别名]
#.........这里部分代码省略.........
if vir[0].hp>vir[0].maxHp:
vir[0].hp=vir[0].maxHp
if vir[0].transHp<=0:
vir[0].isDead=True
def distance(self,a, b):
return sqrt(pow(a.posX - b.posX,2) + pow(a.posY - b.posY,2))
def vel_with_delta(self,deltaX,deltaY,axis):
if axis=='X':
if deltaX>deltaY:
return 1
else:
return deltaX/deltaY
else:
if deltaY>deltaX:
return 1
else:
return deltaY/deltaX
def paint(self, widget, event):
"""Nuestro metodo de pintado propio"""
#Se crea un widget de cairo que despues se usara para desplegar
#todo en la ventana
cr = widget.window.cairo_create()
#Le decimos a cairo que pinte su widget por primera vez.
cr.set_source_rgb(0,0,0)
cr.paint()
#pintar a los agentes
#display_lines(cr, self.annealedCells)
display_simulation(cr,vir,self.annealedCells)
self.hud.display(cr, vir+self.annealedCells)
cr.move_to(5,15)
text="Temperature = %f" % self.currentTemp
cr.show_text(text)
cr.move_to(5,30)
text="Best Energy = %f" % self.bestEnergy
cr.show_text(text)
cr.move_to(5,45)
text="Current Energy = %f" % self.currentEnergy
cr.show_text(text)
#pintar efecto de selección sobre un agente
if self.objetoSeleccionado:
cr.set_line_width(2)
cr.set_source_rgba(random.random(), 1, random.random(), 0.3)
cr.rectangle(self.objetoSeleccionado.posX-20,self.objetoSeleccionado.posY-20,
self.objetoSeleccionado.width+40, self.objetoSeleccionado.height+40)
cr.stroke()
#pintar la información del agente seleccionado
#Para drag & drop
def button_press(self,widget,event):
if event.button == 1:
示例2: main
# 需要导入模块: from hud import Hud [as 别名]
# 或者: from hud.Hud import display [as 别名]
def main():
logg.info("Starting the main function")
# Instancing, etc.
main_view = View().from_rect(FloatRect(0, 0, PP_WIDTH, PP_HEIGHT + BAR_HEIGHT))
window = RenderWindow(
VideoMode(PP_WIDTH * SCALE, (PP_HEIGHT + BAR_HEIGHT) * SCALE), GAME_TITLE + " v." + GAME_VERSION
)
window.framerate_limit = 61
window.view = main_view
# INITIALIZE TEXTURES HERE OR AFTER \o/
TEXTURE_WALL = Texture.load_from_file("main/walls.png")
TEXTURE_BAR = Texture.load_from_file("main/bar.png")
TEXTURE_HUDWEAPONS = Texture.load_from_file("main/hud_weapons.png")
TEXTURE_FACES = Texture.load_from_file("main/faces.png")
TEXTURE_NUMBERS = Texture.load_from_file("main/numbers.png")
TEXTURE_WEAPONS = Texture.load_from_file("main/weapons.png")
TEXTURE_ENEMIES = Texture.load_from_file("main/test.png")
# Create an instance for all game variables and loop functions
# and set the level to TESTLEVEL
game = Gameworld(TEXTURE_ENEMIES)
game.create_dict_map()
game.player.gamemap = game.current_level
game.init_physics()
game.physics.mob_bodies(game.entities)
# prepare the hud
hud = Hud(
player=game.player,
background=TEXTURE_BAR,
faces=TEXTURE_FACES,
hudweapons=TEXTURE_HUDWEAPONS,
weapons=TEXTURE_WEAPONS,
numbers=TEXTURE_NUMBERS,
)
# prepare the wall textures
wall_sprites = game.create_wall_sprite_list(TEXTURE_WALL)
rays = Raycaster(player=game.player, sprites=wall_sprites, gamemap=game.current_level)
# prepare other stuff
player_action = ""
running = True
nofocus = False
##
# MAIN LOOP
##
logg.info("Main loop starting...")
while running:
# iterate events
for event in window.iter_events():
if event.type == Event.CLOSED or player_action == "quit":
running = False
if event.type == Event.LOST_FOCUS:
nofocus = True
elif event.type == Event.GAINED_FOCUS:
nofocus = False
if event.type == Event.KEY_RELEASED:
if game.player.bob > 0: # level the headbobbing
game.player.bob -= 0.5
elif game.player.bob < 0:
game.player.bob += 0.5
game.player.strafing = False
# disable speed limiter for moving in 2 axii
window.clear(Color(235, 235, 235, 255)) # clear the window of everything
for sprite in wall_sprites: # draw walls
window.draw(sprite)
# draw entities here
for entity in game.entities:
if entity.visible == True:
for sprite_slice in entity.sprite:
window.draw(sprite_slice)
hud.display(window) # draw the hud
debug_txt = text(
"["
+ str(draw_fps(frame))
+ "] "
+ str("{0:.2f}".format(game.player.ux))
+ "("
+ str(game.player.x)
#.........这里部分代码省略.........