当前位置: 首页>>代码示例>>Python>>正文


Python Convert.pixel_to_world方法代码示例

本文整理汇总了Python中Convert.pixel_to_world方法的典型用法代码示例。如果您正苦于以下问题:Python Convert.pixel_to_world方法的具体用法?Python Convert.pixel_to_world怎么用?Python Convert.pixel_to_world使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Convert的用法示例。


在下文中一共展示了Convert.pixel_to_world方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import Convert [as 别名]
# 或者: from Convert import pixel_to_world [as 别名]
 def __init__(self, pos, imageurl, scale=()):
     self.pos = pos
     self.imageurl = imageurl
     self.scale = scale
     self.load_image()
     #bounding box is in pixels because it can only have ints
     self.bounding_box = pygame.Rect(Convert.world_to_pixel(pos[0]), Convert.world_to_pixel(pos[1]), self.img.get_width(), self.img.get_height())
     self.width = Convert.pixel_to_world(self.img.get_width()) + 1
     self.height = Convert.pixel_to_world(self.img.get_height()) + 1
     self.dir = [0, 0] #direction: -1, 0, 1
     self.vel = [0, 0] #speeds: any numbers
开发者ID:rystills,项目名称:Oceania,代码行数:13,代码来源:Entity.py

示例2: render_blocks

# 需要导入模块: import Convert [as 别名]
# 或者: from Convert import pixel_to_world [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)
开发者ID:kaikue,项目名称:Oceania,代码行数:17,代码来源:Chunk.py

示例3: render

# 需要导入模块: import Convert [as 别名]
# 或者: from Convert import pixel_to_world [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))
开发者ID:rystills,项目名称:Oceania,代码行数:19,代码来源:Chunk.py


注:本文中的Convert.pixel_to_world方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。