本文整理汇总了Python中ui.UI.draw方法的典型用法代码示例。如果您正苦于以下问题:Python UI.draw方法的具体用法?Python UI.draw怎么用?Python UI.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ui.UI
的用法示例。
在下文中一共展示了UI.draw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GameWindow
# 需要导入模块: from ui import UI [as 别名]
# 或者: from ui.UI import draw [as 别名]
#.........这里部分代码省略.........
if symbol == k.ESCAPE:
logger.info("Exiting...")
pyglet.app.exit()
elif symbol == k.F12:
self.debug = not self.debug
elif symbol == k.F5:
self.game.newgame(self.selected_mapfile)
elif symbol == k.F2:
self.game.add_enemy(*self.get_gamepos(*self.mouse_pos))
if self.game.player:
if symbol == k.W:
self.game.player.move_dir["up"] = True
elif symbol == k.A:
self.game.player.move_dir["left"] = True
elif symbol == k.S:
self.game.player.move_dir["down"] = True
elif symbol == k.D:
self.game.player.move_dir["right"] = True
if symbol == k.F1:
for i in range(50):
self.game.player.levelup(attribute="str")
self.game.player.levelup(attribute="agi")
self.game.player.levelup(attribute="int")
if symbol == k.F3:
self.game.player.die()
if symbol == k.LSHIFT:
self.game.player.actions["sprint"] = True
# Cast abilitites
target = self.get_gamepos(*self.mouse_pos)
if symbol == k._1:
self.game.player.use_ability(1, target=target)
if symbol == k._2:
self.game.player.use_ability(2, target=target)
if symbol == k._3:
self.game.player.use_ability(3, target=target)
if symbol == k._4:
self.game.player.use_ability(4, target=target)
# Level up attributes
if symbol == k.EXCLAMATION:
self.game.player.levelup(attribute="str")
if symbol == k.DOUBLEQUOTE:
self.game.player.levelup(attribute="agi")
if symbol == k.HASH:
self.game.player.levelup(attribute="int")
else:
if symbol == k.F3:
self.game.spawn_player(
self.grid_to_window(*self.game.dungeon.startroom.center)
)
def on_key_release(self, symbol, modifiers):
k = pyglet.window.key
if self.game.player:
if symbol == k.W:
self.game.player.move_dir["up"] = False
elif symbol == k.A:
self.game.player.move_dir["left"] = False
elif symbol == k.S:
self.game.player.move_dir["down"] = False
elif symbol == k.D:
self.game.player.move_dir["right"] = False
if symbol == k.LSHIFT:
self.game.player.actions["sprint"] = False
def update_display_dungeon(self):
x, y = int(self.offset_x), int(self.offset_y)
self.game.dungeon_sprite.x = x
self.game.dungeon_sprite.y = y
self.game.dungeon_overlay_sprite.x = x
self.game.dungeon_overlay_sprite.y = y
def update(self, dt):
if self.game:
self.game.update(dt)
def render(self, dt):
pyglet.gl.glClearColor(*lookup_color("dgrey", gl=True))
self.clear()
pyglet.gl.glEnable(pyglet.gl.GL_DEPTH_TEST)
self.batches["dungeon"].draw()
self.batches["gui0"].draw()
self.batches["creatures"].draw()
self.batches["player"].draw()
self.batches["projectiles"].draw()
if hasattr(self, "animator"):
self.animator.render()
self.batches["dungeon_overlay"].draw()
# enemy_count = pyglet.text.Label(
# text=str(len(self.game.enemies)), font_name=None, font_size=18,
# x=50, y=400, anchor_x="left", anchor_y="top",
# color=lookup_color("black")
# )
# enemy_count.draw()
self.ui.draw()