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


Python Stage.load_level方法代码示例

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


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

示例1: __init__

# 需要导入模块: from stage import Stage [as 别名]
# 或者: from stage.Stage import load_level [as 别名]
class Game:
    
    def __init__(self, world, datadir, configdir):
        self.world = world
        self.datadir = datadir
        self.configdir = configdir
        self.enemies = []

        self.stage = Stage(self)
        self.sprites = Group(self.stage)
        self.screen = world.screen

        # Visor de energia para el enemigo
        self._create_player()
        self.energy = Energy(10, 10, 100, 10)
        self.energy.set_model(self.player.id)

        self.stage.player = self.player
        self.stage.load_level(1)

        if VISIBLE_DEBUG:
            # Visor de rendimiento
            self.text = Text(world.font, world.fps, "FPS: %d")

    def _create_player(self):
        control = Control(0, self.configdir)
        self.player = Player(self, control, self.sprites, self.datadir)
        shadow_player = Shadow(self.player, self.datadir)
        self.sprites.add([self.player, shadow_player])
        
    def update(self):

        self.stage.update()
        self.sprites.update()
        self.energy.update()

        if VISIBLE_DEBUG:
            self.text.update()

        if DEBUG:
            b1, b2, b3 = pygame.mouse.get_pressed()

            if b1:
                self.stage.do_camera_effect()
            elif b2:
                self.stage.do_camera_effect(10)
            elif b3:
                self.world.fps.slow()

    def draw(self):
        self.stage.draw(self.screen)
        self.sprites.draw(self.screen)
        self.screen.blit(self.energy.image, self.energy.rect)

        if VISIBLE_DEBUG:
            self.screen.blit(self.text.image, self.text.rect)

        pygame.display.flip()
开发者ID:HieuLsw,项目名称:sbfury,代码行数:60,代码来源:game.py

示例2: __init__

# 需要导入模块: from stage import Stage [as 别名]
# 或者: from stage.Stage import load_level [as 别名]
class Game:
    "Representa la escena de pelea, donde el shaolin camina por el escenario."
    
    def __init__(self, world):
        self.world = world
        self.enemies = []

        self.sprites = group.Group()
        self.stage = Stage(self, self.sprites)
        self.sprites.camera = self.stage

        self.sprites_in_front = pygame.sprite.RenderPlain()
        self._create_player()
        self.stage.object_to_follow = self.player
        self.stage.load_level(1)

        if VISIBLE_DEBUG:
            # Visor de rendimiento
            self.text = Text(world.font, world.fps, "FPS: %d")
            self.sprites_in_front.add(self.text)

    def _create_player(self):
        self.control = Control()
        self.player = Player(self, self.control, self.sprites, DATADIR)
        self.sprites.add(self.player)
        self.sprites.add(self.player.shadow)
        self.sprites.add(self.player.bandage)

        self.energy = energy.EnergyView(10, 10, self.world.font)
        self.energy.set_model(self.player.energy_model)
        self.sprites_in_front.add(self.energy)

        self.enemy_energy = energy.EnergyView(440, 10, self.world.font)
        self.sprites_in_front.add(self.enemy_energy)

    def handle_event(self, event):
        if event.type == pygame.KEYDOWN:
            self.control.update(event, True)
            if event.key == pygame.K_ESCAPE:
                new_scene = scenes.mainmenu.MainMenu(self.world)
                self.world.change_state(new_scene)
        elif event.type == pygame.KEYUP:
            self.control.update(event, False)
        
    def update(self):
        self.stage.update()
        self.sprites.update()
        self.sprites_in_front.update()

        if DEBUG:
            b1, b2, b3 = pygame.mouse.get_pressed()

            if b1:
                self.stage.do_camera_effect()
            elif b2:
                self.stage.do_camera_effect(10)
            elif b3:
                self.world.fps.slow()

        self.control.post_update()

    def draw(self, screen):
        self.stage.draw(screen)
        self.sprites.draw(screen)
        self.sprites_in_front.draw(screen)
        self.stage.last_draw(screen)
        pygame.display.flip()

    def on_player_energy_model_change(self, model):
        pass

    def on_enemy_energy_model_change(self, model):
        self.enemy_energy.set_model(model)
开发者ID:HieuLsw,项目名称:sbfury,代码行数:75,代码来源:game.py


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