예제 #1
0
    def __init__(self):
        ImageManager.loadSet("player")
        ImageManager.loadSet("effects")
        ImageManager.loadSet(Globals.CURRENT_LEVEL)

        if len(World.groups["HUD"].sprites()) == 0:
            healthHud = Entity.Entity()
            healthHud.componentList.append(CHUDHealth.CHUDHealth())
            World.groups["HUD"].add(healthHud)

            #manaHud = Entity.Entity()
            #manaHud.componentList.append(CHUDMana.CHUDMana())
            #World.groups["HUD"].add(manaHud)

            healthText = Entity.Entity()
            healthText.componentList.append(CHUDHealthText.CHUDHealthText())
            World.groups["HUDText"].add(healthText)

            #manaText = Entity.Entity()
            #manaText.componentList.append(CHUDManaText.CHUDManaText())
            #World.groups["HUDText"].add(manaText)

            scoreText = Entity.Entity()
            scoreText.componentList.append(CHUDScoreText.CHUDScoreText())
            World.groups["HUDText"].add(scoreText)

            sunText = Entity.Entity()
            sunText.componentList.append(CHUDSunText.CHUDSunText())
            World.groups["HUDText"].add(sunText)

            if Globals.CURRENT_LEVEL == "five":
                bossHUD = Entity.Entity()
                bossHUD.componentList.append(CHUDBoss.CHUDBoss())
                World.groups["HUD"].add(bossHUD)

        if Globals.PLAYER is None:
            World.loadMap(Globals.CURRENT_LEVEL)
            World.loadBG(Globals.CURRENT_LEVEL)
            World.initialize()

            entity = Entity.Entity()
            entity.componentList.append(CAnimation.CAnimation(
                ImageManager.levelRes["player"]["Noel_SpriteSheet.png"],
                6, 6, 0, 0.17))
            entity.componentList.append(CPhysics.CPhysics())
            entity.componentList.append(CBasicControl.CBasicControl())
            entity.componentList.append(CCollision.CCollision())
            entity.componentList.append(CView.CView())
            entity.componentList.append(
                CLiving.CLiving(Globals.PLAYER_MAX_HEALTH))
            entity.componentList.append(CDamage.CDamage(Globals.PLAYER_DAMAGE))
            entity.componentList.append(CPlayer.CPlayer())
            entity.componentList.append(CDeathParticle.CDeathParticle(
                ImageManager.levelRes["player"]["Noel_Dead.png"],
                3,
                (0, -20),
                0,
                pygame.BLEND_ADD))
            World.groups["player"].add(entity)
            entity.initialize()
            entity.state = 1
            Globals.PLAYER = entity
            Globals.WIN = False
            Globals.TIME = 120

            zord = Entity.Entity()
            zord.componentList.append(CAnimation.CAnimation(
                ImageManager.levelRes["player"]["Zord_Spritesheet.png"],
                6, 6, 0, 0))
            zord.componentList.append(CPhysics.CPhysics())
            zord.accy = 0
            zord.componentList.append(CAttach.CAttach(entity, 53))
            World.groups["equipment"].add(zord)
            zord.initialize()

            if not Globals.CHECKPOINT_SET or Globals.CURRENT_LEVEL == "five":
                Globals.PLAYER.posx = World.playerPos[0]
                Globals.PLAYER.posy = World.playerPos[1]
            else:
                Globals.PLAYER.posx = float(Globals.getCheckpointPos()[0])
                Globals.PLAYER.posy = float(Globals.getCheckpointPos()[1])

        self.timer = 1.0
        self.bossWinTimer = 4.0

        if AudioManager.loadedMusic != Globals.CURRENT_LEVEL or\
                not pygame.mixer.music.get_busy():
            AudioManager.loadMusic(Globals.CURRENT_LEVEL)
            if AudioManager.loadedMusic == Globals.CURRENT_LEVEL:
                pygame.mixer.music.play(-1)
                if Globals.CURRENT_LEVEL == "five":
                    pygame.mixer.music.set_volume(0.1)

        if not Globals.CURRENT_LEVEL == "five":
            self.sunArray = []
            for sun in Globals.SUN_TRACKER[Globals.CURRENT_LEVEL]:
                self.sunArray.append(sun)