示例#1
0
    def gameBeat(self):
        highScore = readHighScores()
        if self.player.score < highScore[self.worldNumber]:
            worldEndDictionary = {HIGH_SCORE:["High Score For This World: " +str(highScore[self.worldNumber]), "You would need to score " + str(highScore[self.worldNumber] - self.player.score) + " more to beat it!"],
                                  NEXT_WORLD:["Credits", "On to the Credits!"]} 
        elif self.player.score == highScore[self.worldNumber]:
            worldEndDictionary = {HIGH_SCORE:["High Score For This World: " + str(highScore[self.worldNumber]), "You Tied the High Score!"],
                                  NEXT_WORLD:["Credits", "On to the Credits!"]}         
        else:
            worldEndDictionary = {HIGH_SCORE:["High Score For This World: " + str(highScore[self.worldNumber]), "You Beat the High Score!"],
                                  NEXT_WORLD:["Credits", "On to the Credits!"]}         

            highScore[self.worldNumber] = self.player.score
            writeHighScores(highScore)

        utility.dim(128,FILL_COLOR)
        worldEndMenu = menu.Menu(self.screen,
                                 self.musicList[self.worldNumber],
                                 self.screen.convert(),
                                 [0, SCREEN_HEIGHT / 3, SCREEN_WIDTH, SCREEN_HEIGHT],
                                 ["Congratulations!",64,SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4],
                                 worldEndDictionary).displayMenu()

        utility.fadeMusic()
        credits.Credits(self.screen,self.musicList[MENU_MUSIC])
        
        self.done = True
示例#2
0
    def update(self):
        if self.bossDead:
            self.timeAfterBoss += 1

        if self.defaultSpawnRate:
            if not self.moonoSpawnRate:
                self.moonoSpawnRate = self.defaultSpawnRate
                self.spawnMoono()
            self.moonoSpawnRate -= 1

        if self.newMoono.health <= 0:
            self.moonoDead = True

        if self.currentStep == 0:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Welcome to the tutorial!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.currentStep += 1
            self.timer = 0
            
        if self.timer >= 3 * FRAMES_PER_SECOND and self.currentStep == 1:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Use your mouse to move.").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 5 * FRAMES_PER_SECOND and self.currentStep == 2:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Notice the stars that you shoot?").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,3 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)            
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 4 * FRAMES_PER_SECOND and self.currentStep == 3:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "When moving you shoot stars.").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,3 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 4 * FRAMES_PER_SECOND and self.currentStep == 4:
            self.spawnMoono("balloon")

            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Oh no! Its a Moono!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1
        
        if self.timer >= 3 * FRAMES_PER_SECOND and self.currentStep == 5:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Attack with your stars!").image

            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 3 * FRAMES_PER_SECOND and self.currentStep == 6:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Moonos hurt you when they touch you.").image
            self.timer -= 1
            self.moonoDead = False

            helpBubble = infoBubble.infoBubble(tempImage, self.player,3 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 4 * FRAMES_PER_SECOND and self.currentStep == 7:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Did you get the Balloon?").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 3 * FRAMES_PER_SECOND and self.currentStep == 8:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Collect balloons for bonus points!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,3 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)    
            self.timer = 0
            self.currentStep +=1            

        if self.timer >= 4 * FRAMES_PER_SECOND and self.currentStep == 9:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Balloons always help you get more points.").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,3 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 4 * FRAMES_PER_SECOND and self.currentStep == 10:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Points are important!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 3 * FRAMES_PER_SECOND and self.currentStep == 11:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Every 50,000 points you get an extra life!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,3 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        
        if self.timer >= 4 * FRAMES_PER_SECOND and self.currentStep == 12:
            self.spawnBaake()
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Oh bother! It's Baake.").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 3 * FRAMES_PER_SECOND and self.currentStep == 13:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Baakes don't hurt you...").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 3 * FRAMES_PER_SECOND and self.currentStep == 14:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "...but they do love to get in the way!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,3 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 4 * FRAMES_PER_SECOND and self.currentStep == 15:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Its usually best to stay away from Baake.").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,3 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 4 * FRAMES_PER_SECOND and self.currentStep == 16:
            self.spawnMoono("reflect")
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Blast, another Moono!").image
            self.moonoDead = False
            self.timer-= 1

            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 3 * FRAMES_PER_SECOND and self.currentStep == 17:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Did you pickup that powerup gem?").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,3 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 4 * FRAMES_PER_SECOND and self.currentStep == 18:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Gems change how you attack.").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 3 * FRAMES_PER_SECOND and self.currentStep == 19:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "These effects don't last long...").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,3 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 4 * FRAMES_PER_SECOND and self.currentStep == 20:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "...but they do stack!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 3 * FRAMES_PER_SECOND and self.currentStep == 21:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "So pick up as many as you can!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,3 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 4 * FRAMES_PER_SECOND and self.currentStep == 22:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "It is important to make use of gems").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,3 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 4 * FRAMES_PER_SECOND and self.currentStep == 23:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "They can really help you out!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 3 * FRAMES_PER_SECOND and self.currentStep == 24:
            self.defaultSpawnRate = 2.5 * FRAMES_PER_SECOND
            self.massAttack = True
            self.timer = 0
            self.currentStep +=1

        if self.currentStep == 25:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "They're attacking en masse!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 3 * FRAMES_PER_SECOND and self.currentStep == 26:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Try moving slowly towards them.").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 3 * FRAMES_PER_SECOND and self.currentStep == 27:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "You can better control your shots.").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,3 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 4 * FRAMES_PER_SECOND and self.currentStep == 28:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "This can really increase your chances!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,3 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1


        if self.timer >= 4 * FRAMES_PER_SECOND and self.currentStep == 29:
            self.spawnBoss()
            self.bossFight = True
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Oh no! Its a boss!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 3 * FRAMES_PER_SECOND and self.currentStep == 30:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Kill the moonos that spawn.").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer >= 3 * FRAMES_PER_SECOND and self.currentStep == 31:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Some of them will drop a nova.").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1

        if self.timer == 3 * FRAMES_PER_SECOND and self.currentStep == 32:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Use the nova when the boss is near").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1


        if self.timer == 3 * FRAMES_PER_SECOND and self.currentStep == 33:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Only novas can hurt bosses!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)
            self.timer = 0
            self.currentStep +=1
        
        if self.timeAfterBoss == 1 * FRAMES_PER_SECOND:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Congratulations!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)

        if self.timeAfterBoss == 3 * FRAMES_PER_SECOND:
            tempImage = text.TextSurface(FONT_PATH, 30, FONT_COLOR, "Looks like you're ready for a real challenge!").image
            
            helpBubble = infoBubble.infoBubble(tempImage, self.player,2 * FRAMES_PER_SECOND)
            helpBubble.setOffSet(vector.vector2d(0.0,-100.0))
            self.textGroup.add(helpBubble)

        if (self.moonoDead or self.massAttack):
            self.timer += 1

        if self.timeAfterBoss == 5 * FRAMES_PER_SECOND:
            utility.fadeMusic()
            return True
示例#3
0
    if gameIsRunning == START_GAME:
        lastHighlighted = settingList[WORLD_UNLOCKED]
        worldResult = menu.Menu(screen,
                                 musicList[MENU_MUSIC],
                                 newScene,
                                 menuBounds,
                                 ["Choose a World",96,SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4],
                                 worldMenuDictionary,
                                 lastHighlighted).displayMenu()

        if worldResult == TUTORIAL:
            newGame = Game(screen,0,musicList).run()
        elif worldResult == EXIT_OPTIONS:
            worldResult = False
        elif worldResult != False:
            utility.fadeMusic()
            utility.playMusic(musicList[worldResult - 1], True)
            newGame =  Game(screen,worldResult - 1, musicList).run()

    elif gameIsRunning == OPTION_MENU:
        optionResult = True
        lastHighlighted = 0
        while optionResult:

            optionResult = menu.Menu(screen,
                                      musicList[MENU_MUSIC],
                                      newScene,
                                      menuBounds,
                                      ["Options",96,SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4],
                                      optionMenuDictionary,
                                      lastHighlighted).displayMenu()
示例#4
0
    def handleEvents(self):
        for event in pygame.event.get():
            if (event.type == KEYDOWN and event.key == K_ESCAPE) or (event.type == MOUSEBUTTONDOWN and event.button == 3) or (event.type == ACTIVEEVENT and event.gain == 0):
                utility.dim(128,FILL_COLOR)
                """takingScreenShot = True
                while takingScreenShot:
                    for shotEvent in pygame.event.get():
                        if (event.type == pygame.MOUSEBUTTONDOWN):
                            takingScreenShot = False"""

                screenGrab = self.screen.copy()
                
                pauseMenuRunning = True
                
                while pauseMenuRunning:
                    pauseMenu = menu.Menu(self.screen,
                                          self.musicList[self.worldNumber],
                                          screenGrab,
                                          [0, SCREEN_HEIGHT / 3, SCREEN_WIDTH, SCREEN_HEIGHT],
                                          ["Pause",128,SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4],
                                          pauseMenuDictionary).displayMenu()
    
                    if pauseMenu == OPTION_MENU:
                        optionResult = True
                        lastHighlighted = 0
                        while optionResult:
    
                            optionMenuDictionary = {SOUND_MENU:["Sound Options", "Change Sound Options"],
                                                    DISPLAY_MENU:["Video Options" ,"Change Video Options"],
                                                    CHANGE_SENSITIVITY:["Mouse Sensitivity: " + getSensitivity(settingList[SENSITIVITY]), "Change Mouse Sensitivity"],
                                                    EXIT_OPTIONS:["Back","Go Back to the Main Menu"]}
    
                            sensitivityMenuDictionary = {0:["Very Low", "Change Sensitivty to Very Low"],
                                                         1:["Low", "Change Sensitivty to Low"],
                                                         2:["Normal", "Change Sensitivty to Normal"],
                                                         3:["High", "Change Sensitivty to High"],
                                                         4:["Very High", "Change Sensitivty to Very High"],}
                            
                            soundMenuDictionary = {TOGGLE_SFX:["Sound Effects: " + on(settingList[SFX]), "Turn " + on(not settingList[SFX]) + " Sound Effects"],
                                                    TOGGLE_MUSIC:["Music: " + on(settingList[MUSIC]),"Turn " + on(not settingList[MUSIC]) + " Music"],
                                                    EXIT_OPTIONS:["Back","Go Back to the Option Menu"]}
                            
                            displayMenuDictionary = {TOGGLE_PARTICLES:["Particles: " + able(settingList[PARTICLES]), "Turn " + on(not settingList[PARTICLES]) + " Particle Effects"],
                                                    TOGGLE_FULLSCREEN:["Video Mode: " + getScreenMode(settingList[SETTING_FULLSCREEN]), "Switch To " + getScreenMode(not settingList[SETTING_FULLSCREEN]) + " Mode"],
                                                    EXIT_OPTIONS:["Back","Go Back to the Main Menu"]}
    
                            optionResult = menu.Menu(self.screen,
                                                     self.musicList[self.worldNumber],
                                                     screenGrab,
                                                     [0, SCREEN_HEIGHT / 3, SCREEN_WIDTH, SCREEN_HEIGHT],
                                                     ["Options",96,SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4],
                                                     optionMenuDictionary,
                                                     lastHighlighted).displayMenu()
                            
                            if optionResult == SOUND_MENU:
                                soundResult = True
                                lastHighLighted = 0
                                while soundResult:
                                    
                                    soundResult = menu.Menu(self.screen,
                                                            self.musicList[self.worldNumber],
                                                            screenGrab,
                                                            [0, SCREEN_HEIGHT / 3, SCREEN_WIDTH, SCREEN_HEIGHT],
                                                            ["Sound Options",96,SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4],
                                                            soundMenuDictionary,
                                                            lastHighlighted).displayMenu()
                                    
                                    if soundResult == TOGGLE_SFX:
                                        settingList[SFX] = not settingList[SFX]
                                        lastHighlighted = 0
                                    
                                    elif soundResult == TOGGLE_MUSIC:
                                        settingList[MUSIC] = not settingList[MUSIC]
                                        if not settingList[MUSIC]:
                                            pygame.mixer.Channel(MUSIC_CHANNEL).stop()
                                        lastHighlighted = 1
                                        
                                    elif soundResult == EXIT_OPTIONS:
                                        soundResult = False
                                        
                                    soundMenuDictionary = {TOGGLE_SFX:["Sound Effects: " + on(settingList[SFX]), "Turn " + on(not settingList[SFX]) + " Sound Effects"],
                                        TOGGLE_MUSIC:["Music: " + on(settingList[MUSIC]),"Turn " + on(not settingList[MUSIC]) + " Music"],
                                        EXIT_OPTIONS:["Back","Go Back to the Option Menu"]}
                                        
                            if optionResult == DISPLAY_MENU:
                                displayResult = True
                                lastHighlighted = 0
                                while displayResult:
                                    
                                    displayResult = menu.Menu(self.screen,
                                                            self.musicList[self.worldNumber],
                                                            screenGrab,
                                                            [0, SCREEN_HEIGHT / 3, SCREEN_WIDTH, SCREEN_HEIGHT],
                                                            ["Video Options",96,SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4],
                                                            displayMenuDictionary,
                                                            lastHighlighted).displayMenu()           
                            
                                    if displayResult == TOGGLE_PARTICLES:
                                        settingList[PARTICLES] = not settingList[PARTICLES]
                                        lastHighlighted = 0
                                        
                                    elif displayResult == TOGGLE_FULLSCREEN:
                                        settingList[SETTING_FULLSCREEN] = not settingList[SETTING_FULLSCREEN]
                                        lastHighlighted = 1
                                        pygame.mixer.quit()
                                        pygame.mixer.init()
                                        
                                        if settingList[SETTING_FULLSCREEN]:
                                            utility.setFullscreen()
                                        else:
                                            utility.setFullscreen(False)
                                            
                                        pygame.mouse.set_visible(False)
                                        
                                    elif displayResult == EXIT_OPTIONS:
                                        displayResult = False
                                        
                                    displayMenuDictionary = {TOGGLE_PARTICLES:["Particles: " + able(settingList[PARTICLES]), "Turn " + on(not settingList[PARTICLES]) + " Particle Effects"],
                                                            TOGGLE_FULLSCREEN:["Video Mode: " + getScreenMode(settingList[SETTING_FULLSCREEN]), "Switch To " + getScreenMode(not settingList[SETTING_FULLSCREEN]) + " Mode"],
                                                            EXIT_OPTIONS:["Back","Go Back to the Main Menu"]}
                            
                            elif optionResult == EXIT_OPTIONS:
                                optionResult = False
                            
                            elif optionResult == CHANGE_SENSITIVITY:
                                sensitivityResult = True
                                lastHighlighted = 0
                                while sensitivityResult:
                        
                                    sensitivityResult = menu.Menu(self.screen,
                                                                self.musicList[self.worldNumber],
                                                                screenGrab,
                                                                [0, SCREEN_HEIGHT / 3, SCREEN_WIDTH, SCREEN_HEIGHT],
                                                                ["Mouse Sensitivity",96,SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4],
                                                                sensitivityMenuDictionary,
                                                                lastHighlighted).displayMenu()
                
                                    if sensitivityResult == 0:
                                        settingList[SENSITIVITY] = .5
                                        
                                    elif sensitivityResult == 1:
                                        settingList[SENSITIVITY] = .75
                                        sensitivityResult = False
                                        
                                    elif sensitivityResult == 2:
                                        settingList[SENSITIVITY] = 1
                                        sensitivityResult = False
                                        
                                    elif sensitivityResult == 3:
                                        settingList[SENSITIVITY] = 1.25
                                        sensitivityResult = False
                                        
                                    elif sensitivityResult == 4:
                                        settingList[SENSITIVITY] = 1.5
                                        sensitivityResult = False
                                
                    elif pauseMenu == RESUME_GAME or pauseMenu == False:
                        pauseMenuRunning = False
                        pygame.mouse.get_rel()
    
                    elif pauseMenu == EXIT_GAME:
                       utility.fadeMusic()
                       utility.playMusic(self.musicList[MENU_MUSIC], True)
                       self.done = True
                       pauseMenuRunning = False
                                       
            elif event.type == MOUSEMOTION and self.player.lives:
                mousein = [pygame.mouse.get_pos()[0] - 512.0, pygame.mouse.get_pos()[1] - 384.0]
                if mousein[0] != 0 and mousein[1] != 0:
                    self.player.fire()
                    self.player.velocity = (self.player.velocity + mousein) / 1.5 * settingList[SENSITIVITY]
示例#5
0
    def run(self):
        while not self.done:
            if self.worldDone:
                if self.worldNumber < MAX_WORLD:
                    self.worldBeat()

                    """Resetting player lives so that
                    it isn't in their best interest
                    to play easier worlds just to have
                    extra lives."""
                    self.player.lives = 3
                    self.player.lifeBoard.setText('x' + str(self.player.lives))
                    
                    self.player.score = 0
                    self.player.nextBonus = 50000

                    """Loading the new world"""
                    self.worldNumber += 1
                    
                    if self.worldNumber == 0:
                        self.newScene = scene.tutorialScene()
                    elif self.worldNumber == 1:
                        self.newScene = scene.forestScene()
                    elif self.worldNumber == 2:
                        self.newScene = scene.rockyScene()
                    elif self.worldNumber == 3:
                        self.newScene = scene.pinkScene()                     
                    
                    if self.worldNumber > settingList[WORLD_UNLOCKED]:
                        settingList[WORLD_UNLOCKED] = self.worldNumber
                    utility.playMusic(self.musicList[self.worldNumber],True)
                    self.currentWorld = world.World(self.worldList[self.worldNumber], self.musicList[self.worldNumber])
                    self.currentWorld.load()
                    self.worldDone = False
                        
                else:
                    self.gameBeat()

            self.checkCollision()
            self.update()
            self.draw()
            self.handleEvents()
            
            pygame.mouse.set_pos(MOUSE_DEFAULT_POSITION)
            pygame.mouse.get_rel()
            self.mouseLastMove = pygame.mouse.get_pos()
            
            self.timer.tick(FRAMES_PER_SECOND)
     
            if self.player.dead:
                highScore = readHighScores()

                if self.player.score < highScore[self.worldNumber]:
                    endGameDictionary = {HIGH_SCORE:["High Score For This World: " + str(highScore[self.worldNumber]), "You would need to score " + str(highScore[self.worldNumber] - self.player.score) + " more to beat it!"],
                                         NEXT_WORLD:["Exit","Return To The Menu"]} 
                elif self.player.score == highScore[self.worldNumber]:
                    endGameDictionary = {HIGH_SCORE:["High Score For This World: " + str(highScore[self.worldNumber]), "You Tied the High Score!"],
                                         NEXT_WORLD:["Exit","Return To The Menu"]}         
                else:
                    endGameDictionary = {HIGH_SCORE:["High Score For This World: " + str(highScore[self.worldNumber]), "You Beat the High Score!"],
                                         NEXT_WORLD:["Exit","Return To The Menu"]}

                    highScore[self.worldNumber] = self.player.score
                    writeHighScores(highScore)
                utility.dim(128,FILL_COLOR)
                endGameMenu = menu.Menu(self.screen,
                                        self.musicList[self.worldNumber],
                                        self.screen.convert(),
                                        [0, SCREEN_HEIGHT / 3, SCREEN_WIDTH, SCREEN_HEIGHT],
                                        ["Game Over",128,SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4],
                                        endGameDictionary).displayMenu()

                self.done = True
                utility.fadeMusic()
                utility.playMusic(self.musicList[MENU_MUSIC], True)