예제 #1
0
def displayRules():
    import menu
    gameDisplay = pygame.display.set_mode((800, 600))
    pygame.display.set_caption("Rules")

    bg = pygame.image.load('img/RulesView.jpg')

    loop = True
    phase = "rules"

    while loop:
        # Check if user wants to quit
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()

        gameDisplay.fill((0, 0, 0))

        if phase == "rules":
            gameDisplay.blit(bg, (0, 0))
            pygame.display.flip()

            if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
                menu.start_program()
예제 #2
0
def menu_settings():
    import menu
    gameDisplay = pygame.display.set_mode((400, 300))
    pygame.display.set_caption('Music ON/OFF')

    bg = pygame.image.load('img/Wolken.png')

    BackButtonImg = pygame.image.load('img/BackButton.png')
    BackButtonGrayImg = pygame.image.load('img/BackButtonGray.png')
    MusicOnButtonImg = pygame.image.load('img/MusicOn.png')
    MusicONgrayButtonImg = pygame.image.load('img/MusicOngray.png')
    MusicOFFButtonImg = pygame.image.load('img/MusicOFF.png')
    MusicOFFGrayButtonImg = pygame.image.load('img/MusicOFFgray.png')

    # Create instances of the button
    backButton = Button(10, 10, 50, 50, BackButtonImg)
    backButtonGray = Button(10, 10, 50, 50, BackButtonGrayImg)
    MusicButtonON = Button(100, 100, 175, 50, MusicOnButtonImg)
    MusicButtonONGray = Button(100, 100, 175, 50, MusicONgrayButtonImg)
    MusicButtonOFF = Button(100, 153, 175, 50, MusicOFFButtonImg)
    MusicButtonOFFGray = Button(100, 153, 175, 50, MusicOFFGrayButtonImg)

    loop = True
    phase = 'settings'

    while loop:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()

        gameDisplay.fill((0, 0, 0))

        if phase == 'settings':
            gameDisplay.blit(bg, (0, 0))

            gameDisplay.blit(BackButtonGrayImg, (10, 10))
            if Button.buttonHover(backButtonGray):
                gameDisplay.blit(BackButtonImg, (10, 10))
                if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
                    menu.start_program()
#-------------------------------------------------------------------------------------------------
# Music ON/OFF
            gameDisplay.blit(MusicONgrayButtonImg, (100, 100))
            if Button.buttonHover(MusicButtonON):
                gameDisplay.blit(MusicOnButtonImg, (100, 100))
                if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
                    pygame.mixer.music.unpause()

            gameDisplay.blit(MusicOFFGrayButtonImg, (100, 153))
            if Button.buttonHover(MusicButtonOFF):
                gameDisplay.blit(MusicOFFButtonImg, (100, 153))
                if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
                    pygame.mixer.music.pause()

            pygame.display.flip()
예제 #3
0
def walWin():
    width = 800
    height = 600

    size = ((width, height))

    screen = pygame.display.set_mode(size)

    backgroundIMG = pygame.image.load('img/WinGameWal.jpg')
    screen.blit(backgroundIMG, (0, 0))

    pygame.init()

    pygame.display.flip()

    running = True
    while running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                menu.start_program()
예제 #4
0
def highscore_tab():
    import menu
    gameDisplay = pygame.display.set_mode((800, 600))
    pygame.display.set_caption('Highscore')

    bg = pygame.image.load('img/Wolken.png')

    BackButtonImg = pygame.image.load('img/BackButton.png')
    BackButtonGrayImg = pygame.image.load('img/BackButtonGray.png')

    # Create instances of the button
    backButton = Button(10, 10, 50, 50, BackButtonImg)
    backButtonGray = Button(10, 10, 50, 50, BackButtonGrayImg)

    loop = True
    phase = 'settings'

    while loop:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()

        gameDisplay.fill((0, 0, 0))

        if phase == 'settings':
            gameDisplay.blit(bg, (0, 0))

            gameDisplay.blit(BackButtonGrayImg, (10, 10))
            if Button.buttonHover(backButtonGray):
                gameDisplay.blit(BackButtonImg, (10, 10))
                if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
                    menu.start_program()

            black = (0, 0, 0)
            width = 800
            height = 600

            import menu
            # initialize font; must be called after 'pygame.init()' to avoid 'Font not Initialized' error
            myfont = pygame.font.SysFont("monospace", 32)

            conn = psycopg2.connect(database="score",
                                    user="******",
                                    password="******")
            print("Opened database successfully")

            cur = conn.cursor()
            cur.execute("SELECT * FROM score ORDER BY game_win DESC LIMIT 5")
            rows = cur.fetchall()

            xNameNaam = width / 3
            yNameNaam = 100

            xScoreScore = width / 2
            yScoreScore = 100

            xName = width / 3
            yName = 150

            xScore = width / 2
            yScore = 150
            for row in rows:
                # Display "Name" on screen
                labelNameNaam = myfont.render("Name ", 1, black)
                gameDisplay.blit(labelNameNaam, (xNameNaam, yNameNaam))

                # Display Name on screen from Database
                labelName = myfont.render(row[0], 1, black)
                gameDisplay.blit(labelName, (xName, yName))

                # Diplay "Score" on screen
                labelScoreScore = myfont.render("Score", 1, black)
                gameDisplay.blit(labelScoreScore, (xScoreScore, yScoreScore))

                # Display score on screen from Database
                # Cast row[1] van INT naar STRING omdat Font.Render het eerste argument als string pakt
                labelScore = myfont.render(str(row[1]), 1, black)
                gameDisplay.blit(labelScore, (xScore, yScore))
                yName += 30
                yScore += 30

            print("Operation done successfully")
            conn.close()

            pygame.display.flip()
예제 #5
0
def endGame():
    pygame.mixer.music.stop()
    pygame.mixer.music.load('winning_sound.ogg')
    pygame.mixer.music.play(0, 0.0)
    menu.startMusic()
    menu.start_program()