Exemplo n.º 1
0
    def update(self, time):
        if InputManager.getPressed("up"):
            self.selectionID -= 1
            if self.selectionID < 0:
                self.selectionID = 5
            AudioManager.sounds["menu"]["menuSound.ogg"].play()
        elif InputManager.getPressed("down"):
            self.selectionID = (self.selectionID + 1) % 6
            AudioManager.sounds["menu"]["menuSound.ogg"].play()

        if InputManager.getPressed("enter"):
            AudioManager.sounds["menu"]["menuSound.ogg"].play()
            AudioManager.unloadSfxSet("menu")
            if self.selectionID == 0:
                self.enter_game()
            elif self.selectionID == 1:
                self.enter_map()
            elif self.selectionID == 2:
                self.enter_highscore()
            elif self.selectionID == 3:
                self.enter_settings()
            elif self.selectionID == 4:
                self.enter_main()
            elif self.selectionID == 5:
                self.exit_game()
        if InputManager.getPressed("esc"):
            self.enter_game()
        self.time += time
        if self.time < PauseScreen.FADEINTIME:
            ratio = self.time / PauseScreen.FADEINTIME
            value = int(ratio * 255)
            halfValue = int(ratio * 127)
            self.color = pygame.color.Color(value, value, value)
            self.selectedColor =\
                pygame.color.Color(halfValue, value, halfValue)
Exemplo n.º 2
0
    def update(self, time):
        if InputManager.getPressed("up"):
            self.selectionID -= 1
            if self.selectionID < 0:
                self.selectionID = 2
            AudioManager.sounds["menu"]["menuSound.ogg"].play()
        elif InputManager.getPressed("down"):
            self.selectionID = (self.selectionID + 1) % 3
            AudioManager.sounds["menu"]["menuSound.ogg"].play()

        if InputManager.getPressed("enter"):
            AudioManager.sounds["menu"]["menuSound.ogg"].play()
            AudioManager.unloadSfxSet("menu")
            if self.selectionID == 0:
                self.enter_csetup()
            elif self.selectionID == 1:
                Globals.LASTSCREENSETTING = True
                Globals.STATE = ControlScreen.ControlScreen()
            elif self.selectionID == 2:
                self.enter_back()
        if InputManager.getPressed("esc"):
            self.enter_back()
        self.time += time
        if self.time < SettingScreen.FADEINTIME:
            ratio = self.time / SettingScreen.FADEINTIME
            value = int(ratio * 255)
            halfValue = int(ratio * 127)
            self.color = pygame.color.Color(value, value, value)
            self.selectedColor =\
                pygame.color.Color(halfValue, value, halfValue)
Exemplo n.º 3
0
    def update(self, time):
        if InputManager.getPressed("up"):
            self.selectionID -= 1
            if self.selectionID < 0:
                self.selectionID = 3
            AudioManager.sounds["menu"]["menuSound.ogg"].play()
        elif InputManager.getPressed("down"):
            self.selectionID = (self.selectionID + 1) % 4
            AudioManager.sounds["menu"]["menuSound.ogg"].play()

        if InputManager.getPressed("enter"):
            AudioManager.sounds["menu"]["menuSound.ogg"].play()
            AudioManager.unloadSfxSet("menu")
            if self.selectionID == 0:
                self.enter_game()
            elif self.selectionID == 1:
                Globals.STATE = SkillScreen.SkillScreen()
            elif self.selectionID == 2:
                Globals.STATE = MapScreen.MapScreen()
            elif self.selectionID == 3:
                self.enter_main()
        self.time += time
        if self.time < WinScreen.FADEINTIME:
            ratio = self.time / WinScreen.FADEINTIME
            value = int(ratio * 255)
            halfValue = int(ratio * 127)
            self.color = pygame.color.Color(value, value, value)
            self.selectedColor =\
                pygame.color.Color(halfValue, value, halfValue)
 def update(self, time):
     if InputManager.getPressed("enter") or InputManager.getPressed("jump"):
         pygame.mixer.music.stop()
         Globals.STATE = GameScreen.GameScreen()
         return
     self.time += time
     if self.time < EnterFinalScreen.FADEINTIME:
         ratio = self.time / EnterFinalScreen.FADEINTIME
 def update(self, time):
     if InputManager.getPressed("enter") or InputManager.getPressed("jump"):
         #pygame.mixer.music.fadeout(1000)
         Globals.STATE = HighScoreInputScreen.HighScoreInputScreen()
         return
     self.time += time
     if self.time < CompletedGameScreen.FADEINTIME:
         ratio = self.time / CompletedGameScreen.FADEINTIME
     if self.sceneTime > 1.0:
         self.state = (self.state + 1) % 2
         self.sceneTime = 0.0
     self.sceneTime += time
Exemplo n.º 6
0
 def update(self, time):
     if InputManager.getPressed("enter") or InputManager.getPressed("jump"):
         pygame.mixer.music.stop()
         Globals.STATE = GameScreen.GameScreen()
         return
     self.time += time
     if self.time < EnterSnowScreen.FADEINTIME:
         ratio = self.time / EnterSnowScreen.FADEINTIME
     if self.sceneTime > 2.0:
         self.state = (self.state + 1) % 2
         self.sceneTime = 0.0
     self.sceneTime += time
Exemplo n.º 7
0
 def update(self, time):
     if Globals.WIN:
         if Globals.CURRENT_LEVEL == "five":
             if self.bossWinTimer > 0.0:
                 self.bossWinTimer -= time
             else:
                 self.exitFinal()
                 return
         else:
             if Globals.TIME > 0:
                 Globals.SCORE = Globals.SCORE + 10 * int(Globals.TIME)
             self.exitGame()
             return
     if Globals.PLAYER.isDead:
         self.timer -= time
         if self.timer <= 0:
             self.deadScreen()
             return
     if InputManager.getPressed("esc"):
         self.exitScreen()
         return
     Globals.TIME = Globals.TIME - time
     World.update(time)
     if not Globals.CHECKPOINT_SET and\
             Globals.CURRENT_LEVEL in Globals.CHECKPOINT_POS:
         if Globals.PLAYER.rect.x > Globals.getCheckpointPos()[0]:
             Globals.CHECKPOINT_SET = True
Exemplo n.º 8
0
    def update(self, time):
        if InputManager.getPressed("up"):
            self.selectionID -= 1
            if self.selectionID < 0:
                self.selectionID = (Globals.LEVELS_BEAT + 1)
        elif InputManager.getPressed("down"):
            self.selectionID =\
                (self.selectionID + 1) % (Globals.LEVELS_BEAT + 2)

        if InputManager.getPressed("enter"):
            if self.selectionID == 0:
                World.cleanupCompletely()
                Globals.PLAYER = None
                Globals.STATE = EntryScreen.EntryScreen()
                Globals.CURRENT_LEVEL = "one"
            elif self.selectionID == 1 and Globals.LEVELS_BEAT > 0:
                World.cleanupCompletely()
                Globals.PLAYER = None
                Globals.STATE = EnterMountainScreen.EnterMountainScreen()
                Globals.CURRENT_LEVEL = "two"
            elif self.selectionID == 2 and Globals.LEVELS_BEAT > 1:
                World.cleanupCompletely()
                Globals.PLAYER = None
                Globals.STATE = EnterCaveScreen.EnterCaveScreen()
                Globals.CURRENT_LEVEL = "three"
            elif self.selectionID == 3 and Globals.LEVELS_BEAT > 2:
                World.cleanupCompletely()
                Globals.PLAYER = None
                Globals.STATE = EnterSnowScreen.EnterSnowScreen()
                Globals.CURRENT_LEVEL = "four"
            elif self.selectionID == 4 and Globals.LEVELS_BEAT > 3:
                World.cleanupCompletely()
                Globals.PLAYER = None
                Globals.STATE = EnterFinalScreen.EnterFinalScreen()
                Globals.CURRENT_LEVEL = "five"
            elif self.selectionID == (Globals.LEVELS_BEAT + 1):
                self.enter_back()
        if InputManager.getPressed("esc"):
            self.enter_back()
        self.time += time
        if self.time < MapScreen.FADEINTIME:
            ratio = self.time / MapScreen.FADEINTIME
            value = int(ratio * 255)
            halfValue = int(ratio * 127)
            self.color = pygame.color.Color(value, value, value)
            self.selectedColor =\
                pygame.color.Color(halfValue, value, halfValue)
Exemplo n.º 9
0
    def update(self, time):
        if InputManager.getPressed("up"):
            self.selectionID -= 1
            if self.selectionID < 0:
                self.selectionID = 4
            AudioManager.sounds["menu"]["menuSound.ogg"].play()
        elif InputManager.getPressed("down"):
            self.selectionID = (self.selectionID + 1) % 5
            AudioManager.sounds["menu"]["menuSound.ogg"].play()

        if InputManager.getPressed("enter"):
            AudioManager.sounds["menu"]["menuSound.ogg"].play()
            AudioManager.unloadSfxSet("menu")
            if self.selectionID == 0:
                self.enter_game()
            elif self.selectionID == 1:
                self.enter_entry()
            elif self.selectionID == 2:
                self.enter_highScore()
            elif self.selectionID == 3:
                self.enter_settings()
            elif self.selectionID == 4:
                self.exit_title()
        if InputManager.getPressed("esc"):
            self.exit_title()
        self.time += time
        if self.time < MainScreen.FADEINTIME:
            ratio = self.time / MainScreen.FADEINTIME
            value = int(ratio * 255)
            halfValue = int(ratio * 127)
            self.color = pygame.color.Color(value, value, value)
            self.selectedColor =\
                pygame.color.Color(halfValue, value, halfValue)
        self.astoriaToggleTime += time
        if self.astoriaToggleTime < self.astoriaToggleTimeInterval:
            ratio = self.astoriaToggleTime / self.astoriaToggleTimeInterval
            self.astoriaOpacity = int(ratio * 255)
        elif self.astoriaToggleTime < self.astoriaToggleTimeInterval * 2:
            ratio = self.astoriaToggleTime / self.astoriaToggleTimeInterval
            ratio = 1 -\
                (self.astoriaToggleTime - self.astoriaToggleTimeInterval) /\
                self.astoriaToggleTimeInterval
            self.astoriaOpacity = int(ratio * 255)
        else:
            self.astoriaToggleTime = 0
Exemplo n.º 10
0
    def update(self, time):
        if not Globals.LASTSCREENSETTING:
            if InputManager.getPressed("enter") or\
                    InputManager.getPressed("jump"):
                Globals.STATE = EntryScreen.EntryScreen()
            elif InputManager.getPressed("esc"):
                Globals.STATE = MainScreen.MainScreen()
        else:
            if InputManager.getPressed("enter") or\
                    InputManager.getPressed("jump") or\
                    InputManager.getPressed("esc"):
                Globals.STATE = SettingScreen.SettingScreen()
                Globals.LASTSCREENSETTING = False

        self.time += time
        if self.time < ControlScreen.FADEINTIME:
            ratio = self.time / ControlScreen.FADEINTIME
            value = int(ratio * 255)
            halfValue = int(ratio * 127)
            self.color = pygame.color.Color(value, value, value)
            self.selectedColor =\
                pygame.color.Color(halfValue, value, halfValue)
        self.astoriaToggleTime += time
        if self.astoriaToggleTime < self.astoriaToggleTimeInterval:
            ratio = self.astoriaToggleTime / self.astoriaToggleTimeInterval
            self.astoriaOpacity = int(ratio * 255)
        elif self.astoriaToggleTime < self.astoriaToggleTimeInterval * 2:
            ratio = self.astoriaToggleTime / self.astoriaToggleTimeInterval
            ratio = 1 -\
                (self.astoriaToggleTime - self.astoriaToggleTimeInterval) /\
                self.astoriaToggleTimeInterval
            self.astoriaOpacity = int(ratio * 255)
        else:
            self.astoriaToggleTime = 0
Exemplo n.º 11
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
    def update(self, interval):
        if InputManager.getPressed("up"):
            self.ulet = chr(ord(self.ulet) - 1)
        elif InputManager.getPressed("down"):
            self.ulet = chr(ord(self.ulet) + 1)
        elif InputManager.getPressed("enter"):
            self.name.append(self.ulet)
            self.ulet = 'A'
        elif InputManager.getPressed("left"):
            self.name = self.name[:-1]
            self.ulet = 'A'

        if self.ulet < 'A':
            self.ulet = 'Z'
        elif self.ulet > 'Z':
            self.ulet = 'A'

        if len(self.name) == 3:
            f = open('highScores.txt', 'a')
            f.write(self.name[0] + self.name[1] + self.name[2] +
                    " " + str(Globals.SCORE) + "\n")
            f.close()
            Globals.SCORE = 0
            self.exit_screen()
    def update(self, interval):
        if InputManager.getPressed("esc"):
            Globals.STATE = SettingScreen.SettingScreen()
        if self.cExists:
            if self.index < len(InputManager.cList):
                self.iText = "Press button/axis for " +\
                    InputManager.cList[self.index]

            if self.wait == 0.0 and self.index < len(InputManager.cList):
                cInput = InputManager.getControllerInput()
                if cInput[0] != 0:
                    InputManager.cBindings[cInput] =\
                        InputManager.cList[self.index]
                    self.index += 1
                    self.wait = 1.0
            elif self.wait == 0.0:
                InputManager.cConfigured = True
                Globals.STATE = SettingScreen.SettingScreen()
            else:
                self.wait -= interval
                if self.wait < 0.0:
                    self.wait = 0.0
Exemplo n.º 14
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