本文整理汇总了Python中Camera.draw_sprite方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.draw_sprite方法的具体用法?Python Camera.draw_sprite怎么用?Python Camera.draw_sprite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Camera
的用法示例。
在下文中一共展示了Camera.draw_sprite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: import Camera [as 别名]
# 或者: from Camera import draw_sprite [as 别名]
class Game(object):
def __init__(self, screen):
self.deaths = 0
self.screen = screen
self.level = Level('reallevel')
self.spawn()
self.game_area = screen.subsurface((0, 40, screen.get_width(), screen.get_height() - 40))
self.cam = Camera(self.player, self.level.bounds, self.game_area.get_size())
self.hud = screen.subsurface((0, 0, screen.get_width(), 40))
self.deathtext = pygame.font.Font(None, 20)
def spawn(self):
self.player = Player((self.level.spawnPoint), self.level, self)
def quit(self):
self.done = True
def loop(self):
self.done = False
self.clock = pygame.time.Clock()
while not self.done:
dt = self.clock.tick(30)
#input
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.quit()
elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
self.quit()
elif event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE:
self.player.jump()
#update
self.player.update(dt)
self.cam.update(self.player.rect)
#draw
self.hud.fill((80, 80, 80))
text = self.deathtext.render("deaths: " + str(self.deaths), True, (0, 255, 0))
self.hud.blit(text, (0, 0))
self.game_area.fill((0,0,0))
self.cam.draw_background(self.game_area, self.level.background)
self.cam.draw_sprite(self.game_area, self.player)
#refresh
pygame.display.flip()