Example #1
0
    def __init__(self, screen, worldToStart, musicList):
        self.screen = screen

        pygame.mouse.set_visible(False)

        self.done = False
        self.worldDone = False

        self.highScore = 0

        self.bulletGroup = pygame.sprite.Group()
        self.playerGroup = pygame.sprite.Group()
        self.powerupGroup = pygame.sprite.Group()
        self.bossGroup = pygame.sprite.Group()
        self.enemyGroup = pygame.sprite.Group()
        self.textGroup = pygame.sprite.Group()
        self.effectsGroup = pygame.sprite.Group()
        
        self.mouseLastMove = MOUSE_DEFAULT_POSITION

        self.groupList = [self.powerupGroup, self.enemyGroup, self.bossGroup,self.textGroup, self.effectsGroup]

        self.scoreBoard = text.Text(FONT_PATH, 36, FONT_COLOR)
        self.tempLifeBoard = text.Text(FONT_PATH, 36, FONT_COLOR)
        self.tempLifeBoard.position = vector.vector2d(48,40)
        self.lifeBoard = self.tempLifeBoard
        
        self.lifeIcon = icon.Icon("life")
        
        self.player = player.Player(self.bulletGroup, self.effectsGroup, self.lifeBoard, self.scoreBoard)
        
        self.playerGroup.add(self.player)
        self.textGroup.add(self.scoreBoard)
        self.textGroup.add(self.tempLifeBoard)
        self.textGroup.add(self.lifeIcon)

        self.musicList = musicList

        self.timer = pygame.time.Clock()

        """Get rid of the first mouse delta"""
        pygame.mouse.get_rel()

        world1_level0 = [[0,ACTOR_MOONO,45,0],
                         [1,ACTOR_MOONO,120,0],
                         [2,ACTOR_MOONO,240,0],
                         [3,ACTOR_BAAKE,-1,1],
                         [4,ACTOR_BOSS_TUT,-1,1],[4,ACTOR_MOONO,35,0]]
        world1_level1 = [[0,ACTOR_MOONO,40,0],
                         [1,ACTOR_MOONO,85,0],
                         [2,ACTOR_MOONO,110,0],
                         [3,ACTOR_BAAKE,-1,2],
                         [4,ACTOR_BOSS_TUT,-1,1],[4,ACTOR_MOONO,30,0]]
        world1_level2 = [[0,ACTOR_MOONO,30,0],
                         [1,ACTOR_BAAKE,-1,1],[0,ACTOR_MOONO,70,0],
                         [2,ACTOR_BAAKE,-1,1],[0,ACTOR_MOONO,130,0],
                         [3,ACTOR_BAAKE,-1,1],[0,ACTOR_MOONO,300,0],
                         [4,ACTOR_BOSS_TUT,-1,1],[4,ACTOR_MOONO,25,0]]
        world1_level3 = [[0,ACTOR_MOONO,25,0],
                         [1,ACTOR_BAAKE,-1,1],[1,ACTOR_MOONO,50,0],
                         [2,ACTOR_BAAKE,-1,2],[2,ACTOR_MOONO,110,0],
                         [3,ACTOR_BAAKE,-1,2],[3,ACTOR_MOONO,210,0],
                         [4,ACTOR_BOSS_TUT,-1,1],[4,ACTOR_MOONO,20,0]]

        world2_level0 = [[0,ACTOR_MOONO,45,0],[0,ACTOR_HAOYA,65,0],
                         [1,ACTOR_BAAKE,-1,1],[1,ACTOR_MOONO,70,0],
                         [2,ACTOR_HAOYA,75,0],
                         [3,ACTOR_MOONO,85,0],
                         [4,ACTOR_BAAKE_BOSS,-1,1],[4,ACTOR_HAOYA,30,0]]
        world2_level1 = [[0,ACTOR_BAAKE,-1,2], [0,ACTOR_BATTO,150,0],[0,ACTOR_MOONO,55,0],
                         [1,ACTOR_HAOYA,60,0],
                         [2,ACTOR_MOONO,100,0],
                         [3,ACTOR_BAAKE,-1,1],[3,ACTOR_BATTO,280,0],
                         [4,ACTOR_BAAKE_BOSS,-1,1],[4,ACTOR_BATTO,70,0]]
        world2_level2 = [[0,ACTOR_ROKUBI,60,0],[0,ACTOR_MOONO,50,0],[0,ACTOR_BAAKE,-1,2],
                         [1,ACTOR_BAAKE,-1,1],[1,ACTOR_BATTO,160,0],
                         [2,ACTOR_HAOYA,60,0],
                         [3,ACTOR_MOONO,80,0],
                         [4,ACTOR_BAAKE_BOSS,-1,1],[4,ACTOR_ROKUBI,30,0]]
        world2_level3 = [[0,ACTOR_HAOYA,60,0],[0,ACTOR_BATTO,170,0],[0,ACTOR_ROKUBI,75,0],[0,ACTOR_BAAKE,-1,1],
                         [1,ACTOR_MOONO,70,0],[1,ACTOR_BAAKE,-1,1],
                         [2,ACTOR_BAAKE,-1,1],[2,ACTOR_ROKUBI,180,1],
                         [3,ACTOR_MOONO,200,0],
                         [4,ACTOR_BAAKE_BOSS,-1,1],[4,ACTOR_HAOYA,100,0],[4,ACTOR_BATTO,240,0],[4,ACTOR_ROKUBI,90,0],[4,ACTOR_BAAKE,-1,1]]

        world3_level0 = [[0,ACTOR_HAKTA,35,0],[0,ACTOR_HAOYA,65,0],
                         [1,ACTOR_BOKKO,-1,1],
                         [2,ACTOR_BOKKO,-1,1],[2,ACTOR_HAKTA,75,0],
                         [3,ACTOR_BOKKO,-1,1],
                         [4,ACTOR_MOONO_BOSS,-1,1],[4,ACTOR_HAKTA,30,0]]
        world3_level1 = [[0,ACTOR_RAAYU,45,0],[0,ACTOR_HAKTA,50,0],
                         [1,ACTOR_BOKKO,-1,1],
                         [2,ACTOR_RAAYU,60,0],
                         [3,ACTOR_BOKKO,-1,1],[3,ACTOR_ROKUBI,80,0],
                         [4,ACTOR_MOONO_BOSS,-1,1],[4,ACTOR_RAAYU,25,0]]
        world3_level2 = [[0,ACTOR_PAAJO,95,0],[0,ACTOR_HAKTA,40,0],
                         [1,ACTOR_BOKKO,-1,2],
                         [2,ACTOR_RAAYU,80,0],
                         [3,ACTOR_BOKKO,-1,1],
                         [4,ACTOR_MOONO_BOSS,-1,1],[4,ACTOR_PAAJO,70,0]]
        world3_level3 = [[0,ACTOR_HAKTA,55,0],[0,ACTOR_RAAYU,75,0],[0,ACTOR_PAAJO,160,0],
                         [1,ACTOR_BOKKO,-1,2],[1,ACTOR_ROKUBI,50,0],
                         [2,ACTOR_HAOYA,120,0],
                         [3,ACTOR_BOKKO,-1,1],
                         [4,ACTOR_MOONO_BOSS,-1,1],[4,ACTOR_HAKTA,60,0],[4,ACTOR_RAAYU,50,0],[4,ACTOR_PAAJO,110,0],[4,ACTOR_BOKKO,-1,1]]
        
        tutorialWorld = ["Tutorial",self.player,self.groupList]
        tempWorld1 = ["Cloudopolis",self.player,self.groupList,[world1_level0,world1_level1,world1_level2,world1_level3]]
        tempWorld2 = ["Nightmaria",self.player,self.groupList,[world2_level0,world2_level1,world2_level2,world2_level3]]
        tempWorld3 = ["Opulent Dream",self.player,self.groupList,[world3_level0,world3_level1,world3_level2,world3_level3]]

        self.worldList = [tutorialWorld,tempWorld1,tempWorld2,tempWorld3]

        self.worldNumber = worldToStart

        if self.worldNumber == 0:
            self.currentWorld = tutorial.Tutorial(self.worldList[self.worldNumber])
        else:
            self.currentWorld = world.World(self.worldList[self.worldNumber],self.musicList[self.worldNumber])
            self.currentWorld.load()


        if self.worldNumber == 0:
            self.newScene = scene.tutorialScene()
            self.player.lives = 99
            self.lifeBoard.setText('x' + str(self.player.lives))
        elif self.worldNumber == 1:
            self.newScene = scene.forestScene()
        elif self.worldNumber == 2:
            self.newScene = scene.rockyScene()
        elif self.worldNumber == 3:
            self.newScene = scene.pinkScene()       
Example #2
0
menu.loadData()


for event in pygame.event.get():
    pass

splashScreen.SplashScreen(screen,"pygamesplash")
utility.playMusic(musicList[MENU_MUSIC])
splashScreen.SplashScreen(screen,"gameSplash")

if settingList[WORLD_UNLOCKED] == 0:
    newScene = scene.tutorialScene()
elif settingList[WORLD_UNLOCKED] == 1:
    newScene = scene.forestScene()
elif settingList[WORLD_UNLOCKED] == 2:
    newScene = scene.rockyScene()
elif settingList[WORLD_UNLOCKED] == 3:
    newScene = scene.pinkScene() 

try:
    import psyco
    psyco.full()
except:
    print "Warning: Psyco module not installed!"
    print "Continuing happily..."

gameIsRunning = True

mainMenuDictionary = {START_GAME:["Play","Start a New Game"],
                      OPTION_MENU:["Options","Change Sound and Video Options"],
                      CREDIT_MENU:["Credits","Who We Are, What We Did"],
Example #3
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)