So i messing round with pygame because i have an assignment at uni of building a connect 4 game. And so i have it done, so i was trying to make a menu for it. And my problem is, when i click the "JOGAR MULTIPLAYER"(portugues for playing multiplayer) the game starts, and then i have the code for it after 3s return to the main menu. BUT this time, the button "JOGAR MULTIPLAYER" does nothing, it does not show the game again. This is driving me crazyyyyy
def play(): while True: import jogo
jogo
if jogo.fim_de_jogo:
pygame.time.wait(3000)
menu_princ()
pygame.display.update()
def menu_princ(): #Menu Principal while True: WINDOW.blit(BG, (0,0)) #blit - Block Transfer - copia os conteúdos de uma surface/window para outra
pos_mouse = pygame.mouse.get_pos() #get a posição do cursos do mouse
text_menu = font(75).render("MENU", True, "#f873a2")
rect_menu = text_menu.get_rect(center=(350, 75))
play_button = Button(image=pygame.transform.scale(BG_PLAY_BUTTON,(570,109) ), pos=(350, 250), text_input="JOGAR MULTIPLAYER", font=font(30), base_color="#d7fcd4", hovering_color="White")
ai_button = Button(image=pygame.transform.scale(BG_AI_BUTTON,(550,109) ), pos=(350, 400), text_input="JOGAR CONTRA AI", font=font(30), base_color="#d7fcd4", hovering_color="White")
exit_button = Button(image=pygame.transform.scale(BG_EXIT_BUTTON,(195,109) ), pos=(350, 550), text_input="SAIR", font=font(30), base_color="#d7fcd4", hovering_color="White")
WINDOW.blit(text_menu,rect_menu)
for button in [play_button, ai_button, exit_button]:
button.changeColor(pos_mouse)
button.update(WINDOW)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
if play_button.checkForInput(pos_mouse): #se o input for no botão do "JOGAR" - começa o jogo multiplayer
play()
#if ai_button.checkForInput(pos_mouse): #se o input for no botão do "JOGAR CONTRA AI" - começa o jogo contra AI
#play_ai()
if exit_button.checkForInput(pos_mouse): #se o input for no botão do "SAIR" - a janela fecha-se/jogo encerra
pygame.quit()
sys.exit()
pygame.display.update()
menu_princ()
def play() is the function i use to import the game code and the def menu_princ() is the function i use to create the main menu, and the play_button is the button that is not working( it is the 1st button)
I have try everything that i have learned till the moment and can't fix it :(