本文整理汇总了Python中Convert.pixel_to_chunk方法的典型用法代码示例。如果您正苦于以下问题:Python Convert.pixel_to_chunk方法的具体用法?Python Convert.pixel_to_chunk怎么用?Python Convert.pixel_to_chunk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Convert
的用法示例。
在下文中一共展示了Convert.pixel_to_chunk方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render_blocks
# 需要导入模块: import Convert [as 别名]
# 或者: from Convert import pixel_to_chunk [as 别名]
def render_blocks(self, screen, viewport, background):
top = max(Convert.pixel_to_world(viewport.y), 0)
bottom = min(Convert.pixel_to_world(viewport.y + viewport.height) + 1, World.HEIGHT - 1)
for blocky in range(top, bottom):
leftData = Convert.pixel_to_chunk(viewport.x)
rightData = Convert.pixel_to_chunk(viewport.x + viewport.width)
if leftData[1] == self.x:
for blockx in range(leftData[0], WIDTH):
self.render_block(blockx, blocky, screen, viewport, background)
elif leftData[1] < self.x < rightData[1]:
for blockx in range(WIDTH):
self.render_block(blockx, blocky, screen, viewport, background)
elif self.x == rightData[1]:
for blockx in range(0, rightData[0] + 1):
self.render_block(blockx, blocky, screen, viewport, background)
示例2: render
# 需要导入模块: import Convert [as 别名]
# 或者: from Convert import pixel_to_chunk [as 别名]
def render(self, screen, viewport):
top = max(Convert.pixel_to_world(viewport.y), 0)
bottom = min(Convert.pixel_to_world(viewport.y + viewport.height) + 1, World.HEIGHT)
for blocky in range(top, bottom):
leftData = Convert.pixel_to_chunk(viewport.x)
rightData = Convert.pixel_to_chunk(viewport.x + viewport.width)
if leftData[1] == self.x:
for blockx in range(leftData[0], WIDTH):
self.render_block(self.blocks[blocky][blockx], (blockx, blocky), screen, viewport)
elif leftData[1] < self.x < rightData[1]:
for blockx in range(WIDTH):
self.render_block(self.blocks[blocky][blockx], (blockx, blocky), screen, viewport)
elif self.x == rightData[1]:
for blockx in range(0, rightData[0] + 1):
self.render_block(self.blocks[blocky][blockx], (blockx, blocky), screen, viewport)
for entity in self.entities:
entity.render(screen, Convert.world_to_viewport(entity.pos, viewport))