Example #1
0
def displayMap(screen, map_selection):
    if map_selection == 1:
        screen.blit(gameFrame.getImage("Resources/Images/UF_Background.png", images_dictionary), (0,0))
    elif map_selection == 2:
        screen.blit(gameFrame.getImage("Resources/Images/DesolateDesertBG.png", images_dictionary), (0, 0))
    elif map_selection == 0:
        screen.blit(gameFrame.getImage("Resources/Images/Random.png", images_dictionary), (0, 0))
Example #2
0
def endGameMenu(screen, audio, winner):
    # Menu loop
    while True:
        screen.fill((0, 0, 0))
        mx, my = pygame.mouse.get_pos()

        m1_clicked = False
        # Event loop
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                audio.closeAudioEngine()
                pygame.mixer.quit()
                pygame.quit()
                sys.exit()
            if event.type == pygame.MOUSEBUTTONDOWN:
                if event.button == 1:
                    m1_clicked = True
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    game_state["back"] = True


            checkCollision("endgame_back_button", "back", "back", mx, my, m1_clicked)
            checkCollision("restart_button", "restart", "restart", mx, my, m1_clicked)

            #Blit the map that was being played when the victory occurred for added flavor.
            if game_state["map_selection"] == 0:
                screen.blit(gameFrame.getImage("Resources/Images/Random.png", images_dictionary), (0, 0))
            elif game_state["map_selection"] == 1:
                screen.blit(gameFrame.getImage("Resources/Images/UF_Background.png", images_dictionary), (0, 0))
            elif game_state["map_selection"] == 2:
                screen.blit(gameFrame.getImage("Resources/Images/DesolateDesertBG.png" , images_dictionary), (0, 0))


            #Blit a victory message for the player that won the previous match.
            if winner == 1:
                screen.blit(gameFrame.getImage("Resources/Images/Player1Victory.png", images_dictionary), (0,0))
            elif winner == 2:
                screen.blit(gameFrame.getImage("Resources/Images/Player2Victory.png", images_dictionary), (0,0))


            renderMenuButtons("End Game Menu", screen)

            pygame.display.update()


            if game_state["restart"]:
                pygame.time.delay(400)
                game_state["restart"] = False
                gameEngine.startGame(screen, game_state["map_selection"], game_state["p1_skin"], game_state["p2_skin"], audio)
            if game_state["back"]:
                pygame.time.delay(400)
                game_state["back"] = False
                mainMenu(screen, audio)
Example #3
0
def displayPlayer(screen, skin_selection, player_number, player_title):
    if player_number == 1:
        image_path = "Resources/Images/" + skin_selection + "MedR.png"
        menu_buttons["p1_preview"].sprite = image_path
        menu_buttons["p1_preview"].button_rect.center = (100, 225)
        screen.blit(gameFrame.getImage(image_path, images_dictionary), (menu_buttons["p1_preview"].button_rect.x, menu_buttons["p1_preview"].button_rect.y))
        player_text = player_title.render("Player 1", True, (255,255,255))
        player_text_rect = player_text.get_rect()
        player_text_rect.center = (100, 320)
        screen.blit(player_text,player_text_rect)

    else:
        image_path = "Resources/Images/" + skin_selection + "MedL.png"
        menu_buttons["p2_preview"].sprite = image_path
        menu_buttons["p2_preview"].button_rect.center = (900, 225)
        screen.blit(gameFrame.getImage(image_path, images_dictionary), (menu_buttons["p2_preview"].button_rect.x, menu_buttons["p2_preview"].button_rect.y))
        player_text = player_title.render("Player 2", True, (255,255,255))
        player_text_rect = player_text.get_rect()
        player_text_rect.center = (900, 320)
        screen.blit(player_text,player_text_rect)
Example #4
0
def renderMenuButtons(menu_name, screen):
    if menu_name == "Main":
        drawButton(screen, "play_button", 500, 330)
        drawButton(screen, "tutorial_button", 500, 400)
        drawButton(screen, "settings_button", 50, 542)
        drawButton(screen, "exit_button", 500, 540)
        drawButton(screen, "credits_button", 500, 470)
        #Draw the duel logo
        screen.blit(gameFrame.getImage("Resources/Images/MenuTitle.png", images_dictionary), (0,0))

    elif menu_name == "Pregame":
        drawButton(screen, "p1_left_button", 50, 225)
        drawButton(screen, "p1_right_button", 150, 225)
        drawButton(screen, "p2_left_button", 850, 225)
        drawButton(screen, "p2_right_button", 950, 225)
        drawButton(screen, "map_left_button", 300, 50)
        drawButton(screen, "map_right_button", 700, 50)
        drawButton(screen, "pregame_play_button", 850, 555)
        drawButton(screen, "back_button", 150, 555)

    elif menu_name == "Settings":
        drawButton(screen,"minus_button",415, 350)
        drawButton(screen,"plus_button", 585, 350)
        drawButton(screen, "back_button", 500, 450)

    elif menu_name == "Tutorial":
        screen.blit(gameFrame.getImage("Resources/Images/TutorialScreen.png", images_dictionary), (0,0))
        drawButton(screen, "back_button", 140, 555)

    elif  menu_name == "Credits":
        screen.blit(gameFrame.getImage("Resources/Images/CreditsSplashScreen.png", images_dictionary), (0, 0))
        drawButton(screen, "back_button", 130, 560)

    elif menu_name == "Pause":
        drawButton(screen, "play_button", 500, 300)
        drawButton(screen, "restart_button", 500, 350)
        drawButton(screen, "exit_button", 500, 400)

    elif menu_name == "End Game Menu":
        drawButton(screen, "endgame_back_button", 150, 530)
        drawButton(screen, "restart_button", 850, 530)
Example #5
0
def drawButton(screen, button_name, x_pos, y_pos): #This function was not working when I implemented it, need to find a better way to simplify rendering function.
    #Center the button on its x and y coordinates to make it flush with the window.
    menu_buttons[button_name].button_rect.center = (x_pos, y_pos)
    #Blit it to the screen
    screen.blit(gameFrame.getImage(menu_buttons[button_name].sprite, images_dictionary), (menu_buttons[button_name].button_rect.x, menu_buttons[button_name].button_rect.y))