本文整理汇总了Python中Map.render方法的典型用法代码示例。如果您正苦于以下问题:Python Map.render方法的具体用法?Python Map.render怎么用?Python Map.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map.render方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LevelScene
# 需要导入模块: import Map [as 别名]
# 或者: from Map import render [as 别名]
class LevelScene(Scene):
def __init__(self, level_name):
super(LevelScene, self).__init__()
yaml_file = open('levels/' + level_name + '.lvl.yaml')
level_data = yaml.safe_load(yaml_file)
yaml_file.close()
map_data = level_data.get('level')['map']
self.map = Map(map_data)
# doing this in init so that the map will be cached (right?)
# it was in render() without self.{background,overlays} being object
# vars
self.background, overlay_dict = self.map.render()
self.overlays = pygame.sprite.RenderUpdates()
for (x, y), image in overlay_dict.iteritems():
overlay = pygame.sprite.Sprite(self.overlays)
overlay.image = image
overlay.rect = image.get_rect().move(x * 10, y * 10)
def render(self, screen):
screen.fill((230, 230, 230))
screen.blit(self.background, (0, 0))
self.overlays.draw(screen)
pygame.display.flip()
def update(self):
pass
def handle_events(self, events):
# FOR TESTING
for e in events:
if e.type == pygame.KEYDOWN and e.key == pygame.K_TAB:
self.manager.go_to(TitleScene())
if e.type == pygame.KEYDOWN and e.key == pygame.K_1:
self.manager.go_to(LevelScene('1'))
if e.type == pygame.KEYDOWN and e.key == pygame.K_2:
self.manager.go_to(LevelScene('2'))