本文整理汇总了Python中Camera.Camera.toScreen方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.toScreen方法的具体用法?Python Camera.toScreen怎么用?Python Camera.toScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Camera.Camera
的用法示例。
在下文中一共展示了Camera.toScreen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: JamMode
# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import toScreen [as 别名]
class JamMode(JamModeUpdate, GameMode):
def __init__(self):
GameMode.__init__(self)
self.camera = Camera((700,400), (), 10, 100)
self.court = Court()
self.entities = []
self.physics = CapsuleManager(Court.getBounds())
self.totalTime = 0
self.font = pygame.font.SysFont(None, 36)
self.score = [0, 0]
def init(self):
self.player = self.addEntity(Baller(Vec3d(0, 0, 0)))
self.computer = self.addEntity(Baller(Vec3d(5, 0, 0)))
self.computer.input = AIController(self.computer)
self.computer.color = 0x00AAFF
self.computer.net = 1
self.ball = self.addEntity(Ball(Vec3d(0, 0, 0)))
def goal(self, net, points):
self.score[(net + 1) / 2] += points
def addEntity(self, entity):
self.physics.addCapsule(entity.capsule)
self.entities.append(entity)
entity.register(self)
return entity
def draw(self, canvas):
self.court.draw(self.camera, canvas)
self.entities = sorted(self.entities, key=lambda entity: -entity.pos.z)
for entity in self.entities:
entity.draw(canvas, self.camera.toScreen(entity.pos), self.camera.getDepthModifier(entity.pos))
text = self.font.render("%d:%d" % (self.score[1], self.score[0]), False, (0, 0, 0))
canvas.blit(text, (340, 15))