本文整理汇总了Python中Convert.world_to_pixels方法的典型用法代码示例。如果您正苦于以下问题:Python Convert.world_to_pixels方法的具体用法?Python Convert.world_to_pixels怎么用?Python Convert.world_to_pixels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Convert
的用法示例。
在下文中一共展示了Convert.world_to_pixels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: import Convert [as 别名]
# 或者: from Convert import world_to_pixels [as 别名]
def update():
for event in pygame.event.get():
if event.type == pygame.QUIT:
close()
elif event.type == pygame.MOUSEBUTTONDOWN:
if gamemode == MENU:
menu.mouse_press()
if gamemode == PLAYING:
world.break_block(player, pygame.mouse.get_pos(), viewport)
elif event.type == pygame.MOUSEBUTTONUP:
if gamemode == MENU:
menu.mouse_release()
elif event.type == pygame.KEYDOWN:
if pygame.key.get_pressed()[pygame.K_e]:
global gui
if gui is None:
gui = InventoryGUI.InventoryGUI(player)
else:
gui = None
if pygame.key.get_pressed()[pygame.K_F3]:
global DEBUG
DEBUG = not DEBUG
pressed = pygame.key.get_pressed()
if pressed[pygame.K_ESCAPE]:
close()
if gamemode == MENU:
menu.update()
elif gamemode == PLAYING:
player.dir = [0, 0]
if pressed[pygame.K_LEFT] or pressed[pygame.K_a]:
player.dir[0] -= 1
if pressed[pygame.K_RIGHT] or pressed[pygame.K_d]:
player.dir[0] += 1
if pressed[pygame.K_UP] or pressed[pygame.K_w]:
player.dir[1] -= 1
if pressed[pygame.K_DOWN] or pressed[pygame.K_s]:
player.dir[1] += 1
player.update(world)
viewport.x = Convert.world_to_pixels(player.pos)[0] - SCREEN_WIDTH / 2 #replace with center
viewport.y = Convert.world_to_pixels(player.pos)[1] - SCREEN_HEIGHT / 2
world.update()