0

My code is for a game that requires the user to select a character in a pregame screen and then this value is globalised so that a player sprite can be created which uses this value to determine the image to use in another screen. This image is also displayed on the screen for the user to see in the pregame screen. But after the button for the character is clicked the display character only displays for a split second, how do I make it so that its stays on the screen.

    choice = [redboy_left, capboy_left, girl_left]
    display =[newredboy_left, newcapboy_left, newgirl_left]

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
        if event.type == pygame.MOUSEBUTTONDOWN:
            if oneplayer_back.checkForInput(ONEPLAYER_MOUSE_POS):
                mixer.music.play()
                main_menu()
            if redboyleft_button.checkForInput(ONEPLAYER_MOUSE_POS):
                mixer.music.play()
                player1_choice = choice[0]
                display_character = display[0]
                print("RED")
                screen.blit(display_character,(900,200))
            if capboyleft_button.checkForInput(ONEPLAYER_MOUSE_POS):
                mixer.music.play()
                player1_choice = choice[1]
                display_character = display[1]
                print("CAP")
                screen.blit(display_character,(900,200))
            if girlleft_button.checkForInput(ONEPLAYER_MOUSE_POS):
                mixer.music.play()
                player1_choice = choice[2]
                display_character = display[2]
                print("GIRL")
                screen.blit(display_character,(900,200))
            if play_button.checkForInput(ONEPLAYER_MOUSE_POS):
                mixer.music.play()
                one_player()

            global selected_character1
            selected_character1 = player1_choice
                
    pygame.display.update()
Rabbid76
  • 202,892
  • 27
  • 131
  • 174

0 Answers0