本文整理汇总了Python中Convert.pixels_to_viewport方法的典型用法代码示例。如果您正苦于以下问题:Python Convert.pixels_to_viewport方法的具体用法?Python Convert.pixels_to_viewport怎么用?Python Convert.pixels_to_viewport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Convert
的用法示例。
在下文中一共展示了Convert.pixels_to_viewport方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: import Convert [as 别名]
# 或者: from Convert import pixels_to_viewport [as 别名]
def render():
if gamemode == MENU:
menu.render(screen)
elif gamemode == PLAYING:
screen.fill(SKY)
world.render(screen, viewport)
if DEBUG:
#render debug text
h = 10
fpsimg = font.render("fps: " + str(clock.get_fps()), 0, WHITE)
screen.blit(fpsimg, (10, h))
h += fpsimg.get_height()
posimg = font.render("pos: [{0:.2f}".format(player.pos[0]) + ", {0:.2f}]".format(player.pos[1]), 0, WHITE)
screen.blit(posimg, (10, h))
h += posimg.get_height()
chunk = world.loaded_chunks.get(Convert.world_to_chunk(player.pos[0])[1])
chunkimg = font.render("chunk: " + str(chunk.x), 0, WHITE)
screen.blit(chunkimg, (10, h))
h += chunkimg.get_height()
biomeimg = font.render("biome: " + str(chunk.biome["name"]), 0, WHITE)
screen.blit(biomeimg, (10, h))
h += biomeimg.get_height()
player.render(screen, Convert.world_to_viewport(player.pos, viewport))
if gui is None:
target_pos = world.find_pos(world.find_angle(player, pygame.mouse.get_pos(), viewport),
Convert.pixels_to_viewport(player.pixel_pos(True), viewport),
pygame.mouse.get_pos(),
player.get_break_distance())
screen.blit(img_target, [x - y for x, y in zip(target_pos, [dim / 2 for dim in img_target.get_size()])]) #zoo-wee mama!
else:
gui.render(screen)
pygame.display.flip()
示例2: render
# 需要导入模块: import Convert [as 别名]
# 或者: from Convert import pixels_to_viewport [as 别名]
def render(self, screen, pos):
#temporary bounding box
pygame.draw.rect(screen, Game.RED, \
pygame.rect.Rect(Convert.pixels_to_viewport(self.bounding_box.topleft, Game.get_viewport()),
(self.bounding_box.width, self.bounding_box.height)))