本文整理汇总了Python中Camera.render方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.render方法的具体用法?Python Camera.render怎么用?Python Camera.render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Camera
的用法示例。
在下文中一共展示了Camera.render方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: World
# 需要导入模块: import Camera [as 别名]
# 或者: from Camera import render [as 别名]
class World(object):
"""The world class which stores entities and value data."""
def __init__(self, size, player, viewport):
self.size = size
self.center = size*.5
self.player = player
self.terrain\
= [[Terrain.Grass if y%2 is 0 else Pixel.Black for y in range(size.y)] for x in range(size.x)]
self.entities = [player]
self.camera = Camera(self.player.pos, viewport, self.center)
def input(self, input):
#this takes in the input from self.request.get('input')
self.player.handleInput(self, input)
pass
def update(self):
for ent in self.entities:
ent.update(self)
pass
def render(self):
buffer = copy.deepcopy(self.terrain) #COMPOSED OF PIXELS
#PLACE ENTITIES
for ent in world.entities:
pos = self.buffercoord(ent.pos)
if(not ((pos.x < 0 or pos.x > self.size.x)
or (pos.y < 0 or pos.y > self.size.y))):
buffer[pos.x][pos.y] = ent
return self.camera.render(buffer, self)
def buffercoord(self, vect):
floatVect = vect + self.size*.5
return Vector(int(floatVect.x), int(floatVect.y))
def worldcoord(self, vect):
return vect - self.size*.5