def runGame():
    Game.mainDecision=True
    Game.mainDecision2=True

    decision = True
    decision2 = True
    decision3=False
    pygame.mixer.music.play(100,0.0)

    while Game.mainDecision==True and Game.mainDecision2==True:

        if decision==True and decision2==True:
            scr.blit(bg,screen)     #initialize screen
            gameTitle = menufont.render('Bubble Fantasy',1,(135,206,235))
            highScore=menu2font.render('High Score: '+readHighScore(),1,(245,245,245))
            scr.blit(gameTitle,(140,150))
            scr.blit(highScore,(190,200))
            display.flip()

            menu_ = ('Start Game','Help','View High Scores','Return to Game Suite Menu','Quit')   #Main menu
            pygame.mouse.set_visible(True)
            choice = menu(menu_,color1=(175,238,238),light=10,speed=300)[0]
            if choice == 'Quit': Game.mainDecision=False

            elif choice=='Return to Game Suite Menu':
                Game.mainDecision2=False
                pygame.mixer.music.stop()

            elif choice == 'Start Game':    #Initialize the game based on the difficulty chosen by player
                scr.blit(bg,screen)
                display.flip()
                help()
                menu_=('Continue to Game','','')
                choice5=menu(menu_,pos='bottomleft',font1=menu3font, color1=(200,200,200),light=10,justify=False,speed=0)[0]
                if choice5=='Continue to Game':
                    scr.blit(bg,screen)
                    display.flip()
                    title=menu2font.render('Choose a Difficulty Level',1,(135,206,235))
                    scr.blit(title,(180,200))
                    display.flip()
                    menu_ = ('Beginner','Easy','Normal','Hard','Impossible')#Let user choose difficulty level
                    choice3=menu(menu_,pos='center',font1=menu2font, color1=(200,200,200),light=10,justify=False,speed=0)[0]
                    if choice3!='Beginner' and choice3!='Easy' and choice3!='Normal' and choice3!='Hard' and choice3!='Impossible':
                        Game.mainDecision=False
                    else:
                        Game.init(choice3)
                        gameLoop()
                        if Game.status == 2:    #Ends game when the game's status indicates game over or new high score
                            print "A"
                            endGame()
                            decision2=False
                        elif Game.status in (2,3): print "B"; endGame(); decision2=False; decision3=True
                else: Game.mainDecision=False

            elif choice=='Help':    #Displays help for the player by calling up the function help()
                scr.blit(bg,screen)
                display.flip()
                help()
                menu_=('Return to Main Menu','','')
                choice4=menu(menu_,pos='bottomleft',font1=menu3font,color1=(200,200,200),light=10,justify=False,speed=0)[0]
                if choice4=='Return to Main Menu':
                    scr.blit(bg,screen)
                    display.flip()

            elif choice=='View High Scores':#Displays a list of the top 15 high scores
                title=menu2font.render('Top 15 High Scores',1,(245,245,245))
                scr.blit(bg,screen)
                scr.blit(title,(222,20))
                display.flip()
                viewHighScores()
                menu_=('Return to Main Menu','Clear All Scores','')#Allows user to clear all scores
                choice4=menu(menu_,pos='bottomleft',font1=menu3font,color1=(200,200,200),light=10,justify=False,speed=0)[0]
                if choice4=='Return to Main Menu':
                    scr.blit(bg,screen)
                    display.flip()
                elif choice4=='Clear All Scores':
                    clearScores()
                else:
                    Game.mainDecision=False

            else: Game.mainDecision=False

        if choice!='Help' and choice!='View High Scores':
            decision=False

        if Game.mainDecision==True and Game.mainDecision2==True and decision==False and decision2==True: #In-game pause menu, when game is not over
            menu_ = ('Resume Game','Restart Game','Help','Main Menu')
            pygame.mouse.set_visible(True)
            choice2 = menu(menu_,pos='bottomleft',font1=menu3font,color1=(200,200,200),light=10,justify=False,speed=0)[0]
            if choice2 == 'Main Menu':
                scr.blit(bg,screen)
                display.flip(); choice = None; decision=True
            elif choice2=='Resume Game':    #Resumes main game loop
                gameLoop()
                if Game.status == 2:
                    endGame(); decision2=False
                elif Game.status in (2,3): endGame(); decision2=False; decision3=True
            elif choice2=='Help':   #Displays help for the player by calling up the function help()
                scr.blit(bg,screen)
                display.flip()
                help()
                menu_=('Return to Game','','')
                choice4=menu(menu_,pos='bottomleft',font1=menu3font,color1=(200,200,200),light=10,justify=False,speed=0)[0]
                if choice4=='Return to Game':
                    scr.blit(bg,screen)
                    display.flip()
                    gameLoop()
                    if Game.status == 2:    #Ends game when the game's status indicates game over or new high score
                        endGame(); decision2=False
                    elif Game.status in (2,3): endGame(); decision2=False; decision3=True
            elif choice2=='Restart Game': #Re-initializes game and main loop if user wants to restart the game
                scr.blit(bg,screen)
                title=menu2font.render('Choose a Difficulty Level',1,(135,206,235))
                scr.blit(title,(180,200))
                display.flip()
                menu_ = ('Beginner','Easy','Normal','Hard','Impossible')#Let user choose difficulty level
                choice3=menu(menu_,pos='center',font1=menu2font, color1=(200,200,200),light=10,justify=False,speed=0)[0]
                if choice3!='Beginner' and choice3!='Easy' and choice3!='Normal' and choice3!='Hard' and choice3!='Impossible':
                    Game.mainDecision=False
                else:
                    Game.init(choice3)
                    gameLoop()
                    if Game.status == 2:    #Ends game when the game's status indicates game over or new high score
                        print "C"; endGame()
                    elif Game.status in (2,3): print "D"; endGame(); decision2=False

            else: Game.mainDecision=False

        elif Game.mainDecision==True and Game.mainDecision2==True and decision2==False: #In-game menu when game is over
            menu_ = ('Restart Game','Main Menu','')
            pygame.mouse.set_visible(True)
            if decision3==True: decision2=True
            choice2 = menu(menu_,pos='bottomleft',font1=menu3font,color1=(200,200,200),light=10,justify=False,speed=0)[0]
            if choice2 == 'Main Menu':  #Displays the main menu
                scr.blit(bg,screen)
                display.flip()
                choice = None;decision2=True;decision=True
            elif choice2=='Restart Game': #Re-initializes game and main loop if user wants to restart the game
                scr.blit(bg, screen)
                title=menu2font.render('Choose a Difficulty Level',1,(135,206,235))
                scr.blit(title,(180,200))
                display.flip()
                menu_ = ('Beginner','Easy','Normal','Hard','Impossible')#Let user choose difficulty level
                choice3=menu(menu_,pos='center',font1=menu2font, color1=(200,200,200),light=10,justify=False,speed=0)[0]
                if choice3!='Beginner' and choice3!='Easy' and choice3!='Normal' and choice3!='Hard' and choice3!='Impossible':
                    Game.mainDecision=False
                else:
                    Game.init(choice3)
                    gameLoop()
                    if Game.status == 2:    #Ends game when the game's status indicates game over or new high score
                        print "E"; endGame(); decision2=True
                    elif Game.status in (2,3):
                        print "F"; endGame(); decision2=False
            else: Game.mainDecision=False

    if Game.mainDecision2==True:
        quit()
        pygame.quit()


#For Testing Purposes#
#runGame()
Exemple #2
0
def endmess():
    label = messfont.render('YOU WIN'if Game.status==2 else'YOU LOSE' ,1,(10,10,10))
    rlabel = label.get_rect(center=ball_rect.center)
    scr.blit(label,rlabel)
    display.flip()

choix = None
resume = False
scr.blit(bg,screen)
display.flip()
while True:
    if not choix:
        if Challenge.levels: menu_ = ('Classic','Challenge','Editor','Quit Game')
        else: menu_ = ('Classic','Editor','Quit Game')
        choix = menu(menu_,color1=(150,150,200),light=10,speed=300)[0]
    if choix == 'Quit Game': break
    elif choix == 'Classic':
        if not resume: Game.init()
        else: resume = False
        game_mainloop()
        if Game.status == 2: save_hightscore('Classic')
        if Game.status in (2,3): endmess()
    elif choix == 'Editor':
        if not resume: Editor.init()
        else: resume = False
        editor_mainloop()
    elif choix == 'Challenge':
        if not resume: Challenge.init()
        else: resume = False
        challenge_mainloop()
Exemple #3
0
This file runs the menu that allows you to play all the available games in
the suite. The games are Bubble Fantasy, Ball Dodger, Pong and Penalty Shootout.
"""
menuDecision = True

while menuDecision == True:
    title = menufont.render("Castor Game Suite", 1, (255, 255, 255))
    title2 = menu5font.render("Pick any of the games below to get started", 1, (255, 255, 255))
    scr.blit(bg, screen)
    scr.blit(title, (105, 80))
    scr.blit(title2, (135, 130))
    display.flip()
    menu_ = ("Bubble Fantasy", "Ball Dodger", "Pong", "Penalty Shootout")
    pygame.mouse.set_visible(True)
    choice = menu(menu_, color1=(255, 255, 255), light=10, speed=300)[0]
    if choice == "Ball Dodger":
        scr.blit(bg, screen)
        display.flip()
        pygame.display.set_caption("Ball Dodger")
        menu_ = ("Easy", "Medium", "Hard")
        choice2 = menu(menu_, color1=(175, 238, 238), light=10, speed=300)[0]
        if choice2 != "Easy" and choice2 != "Medium" and choice2 != "Hard":
            menuDecision = False
        else:
            scores = highscore()
            ballDodgerRun(choice2, scores)
            if scores.mainDecision == False:
                menuDecision = False
    elif choice == "Bubble Fantasy":
        pygame.display.set_caption("Bubble Fantasy")
Exemple #4
0
def endmess():
    label = messfont.render('YOU WIN'if Game.status==2 else'YOU LOSE' ,1,(10,10,10))
    rlabel = label.get_rect(center=ball_rect.center)
    scr.blit(label,rlabel)
    display.flip()

pygame.init()
choix = None
resume = False
scr.blit(bg,screen)
display.flip()
while True:
    if not choix:
        if Challenge.levels: menu_ = ('Classic','Challenge','Editor','Quit Game')
        else: menu_ = ('Classic','Editor','Quit Game')
        choix = menu(menu_,color1=(150,150,200),light=10,speed=300)[0]
    if choix == 'Quit Game': break
    elif choix == 'Classic':
        if not resume: Game.init()
        else: resume = False
        mixer.music.load('res/Dungeon9.ogg')
        mixer.music.play(-1, 0.0)
        game_mainloop()
        if Game.status == 2: save_hightscore('Classic')
        if Game.status in (2,3): endmess()
        mixer.music.stop()
    elif choix == 'Editor':
        if not resume: Editor.init()
        else: resume = False
        editor_mainloop()
    elif choix == 'Challenge':