Exemplo n.º 1
0
 def update(self, time):
     if InputManager.getAction("jump") or InputManager.getAction("enter"):
         self.enter_main()
     self.time += time
     if self.time < TitleScreen.FADEINTIME and self.FADEIN:
         if not self.GGames and not self.soundPlaying:
             self.text = "Astoria"
             AudioManager.sounds["title"]["staticRustle.ogg"].play()
             self.soundPlaying = True
         ratio = self.time / TitleScreen.FADEINTIME
         value = int(ratio * 255)
         self.color = pygame.color.Color(value, value, value)
     elif self.time < TitleScreen.FADEOUTTIME and not self.FADEIN:
         ratio = 1.0 - self.time / TitleScreen.FADEOUTTIME
         value = int(ratio * 255)
         self.color = pygame.color.Color(value, value, value)
     else:
         self.time = 0
         if not self.FADEIN:
             if self.GGames:
                 self.GGames = False
                 TitleScreen.FADEINTIME = 4.0
             else:
                 self.enter_main()
         self.FADEIN = not self.FADEIN
     self.width, self.height = Globals.FONT.size(self.text)
     self.temp = Globals.FONT.render(self.text, True, self.color)
Exemplo n.º 2
0
 def update(self, entity, interval):
     if entity.posx > Globals.WIN_POS:
         Globals.WIN = True
     entity.regen_time += interval
     if entity.regen_time >= Globals.PLAYER_REGEN_TIME:
         if entity.health < Globals.PLAYER_MAX_HEALTH:
             entity.health += 1
         if entity.mp < Globals.PLAYER_MAX_MP:
             entity.mp += 1
         entity.regen_time = 0.0
     if InputManager.getPressed("debugMode"):
         Globals.DEBUG_MODE = not Globals.DEBUG_MODE
     if InputManager.getAction("cheat1") and Globals.DEBUG_MODE:
         entity.health = Globals.PLAYER_MAX_HEALTH
     if InputManager.getPressed("cheat2") and Globals.DEBUG_MODE:
         Globals.WIN = True
         if Globals.CURRENT_LEVEL == "five":
             Globals.GAMECOMPLETED = True
     if InputManager.getPressed("cheat3") and Globals.DEBUG_MODE:
         Globals.MINI_SUNS += 1
     if InputManager.getPressed("cheatPos") and Globals.DEBUG_MODE:
         print Globals.PLAYER.rect.x, Globals.PLAYER.rect.y
Exemplo n.º 3
0
    def update(self, entity, interval):
        if entity.stunTimeout > 0:
            entity.state = 5
            entity.sAnim = 0
            if entity.isGrounded:
                entity.velx = 0
        else:
            if InputManager.getPressed("attack1") and not entity.isAttacking:
                if entity.equipType == CAttach.ZORD:
                    entity.state = 4
                    entity.sAnim = 0
                    entity.asAnimEnd = 2
                elif entity.equipType == CAttach.BOW and\
                        self.bowCooldown == 0.0:
                    entity.state = 3
                    entity.sAnim = 0
                    entity.asAnimEnd = 2

                    aimg = ImageManager.levelRes["player"]["Arrow.png"]
                    if entity.faceRight:
                        vel = Globals.ARROW_VELOCITY
                    else:
                        vel = -Globals.ARROW_VELOCITY
                        aimg = pygame.transform.flip(aimg, True, False)
                    arrow = Entity.Entity()
                    arrow.componentList.append(CPhysics.CPhysics())
                    arrow.componentList.append(CCollision.CCollision())
                    arrow.componentList.append(CProjectile.CProjectile(
                        aimg,
                        (entity.posx + 3.0, entity.posy + 60.0),
                        (vel, -5.0),
                        (0.0, 9.0),
                        Globals.ARROW_HITS))
                    arrow.componentList.append(
                        CDamage.CDamage(Globals.ARROW_DAMAGE))
                    arrow.initialize()
                    World.groups["pProjectile"].add(arrow)
                    self.bowCooldown = Globals.BOW_COOLDOWN
                entity.isAttacking = True
            if InputManager.getAction("left"):
                entity.velx = - MOVE_AMOUNT
                if entity.isGrounded and not entity.isAttacking:
                    entity.state = 1
                entity.faceRight = False
            elif InputManager.getAction("right"):
                entity.velx = MOVE_AMOUNT
                if entity.isGrounded and not entity.isAttacking:
                    entity.state = 1
                entity.faceRight = True
            elif not entity.isAttacking:
                entity.velx = 0
                if entity.isGrounded:
                    entity.state = 0
            if InputManager.getPressed("jump") and\
                    entity.isGrounded and not entity.isAttacking:
                entity.vely = - Globals.PLAYER_JUMP
                entity.isGrounded = False
                entity.state = 2
            if InputManager.getPressed("sword"):
                World.groups["equipment"].empty()

                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()
            elif InputManager.getPressed("bow"):
                World.groups["equipment"].empty()

                bow = Entity.Entity()
                bow.componentList.append(CAnimation.CAnimation(
                    ImageManager.levelRes[
                        "player"]["BowArrow_Spritesheet.png"],
                    6, 6, 0, 0))
                bow.componentList.append(CPhysics.CPhysics())
                bow.accy = 0
                bow.componentList.append(
                    CAttach.CAttach(entity, 28, CAttach.BOW))
                World.groups["equipment"].add(bow)
                bow.initialize()
        self.bowCooldown -= interval
        if self.bowCooldown < 0.0:
            self.bowCooldown = 0.0