I'm currently making a menu for my game in python. And I encountered a problem with code, that switches between different menu pages. When it needed to switch, it just switched for a little less than a second and then returned to the main page. I searched the web and found out, that I need to use return and so I did. However it did nothing. Then I figured I should add break, since loop is maybe still running. And I did that as well, however still nothing changed. I tried to search the web further, but no one seemed to have problem with return not working, no matter how widely I searched. So I figured I should ask on this forum.
Here's the code in question:
Here's the code in question:
def menu(): screen.blit(ozadje, (0, 0)) screen.blit(naslov_menija, (440, 210)) screen.blit(avtor, (450, 270)) choice10 = (440, 305, 210, 30) choice11 = (440, 300, 280, 30) choice20 = (440, 335, 140, 30) choice21 = (440, 335, 173, 30) choice30 = (440, 365, 70, 30) choice31 = (440, 365, 90, 30) mouse = pygame.mouse.get_pos() if lang == 0: screen.blit(singleplayer, (440, 300)) if mouse[0] > choice10[0] and mouse[0] < choice10[0] + choice10[2]: if mouse[1] > choice10[1] and mouse[1] < choice10[1] + choice10[3]: pygame.draw.rect(screen, red, choice10, 3) elif lang == 1: screen.blit(enoigralski_nacin, (440, 300)) if mouse[0] > choice11[0] and mouse[0] < choice11[0] + choice11[2]: if mouse[1] > choice11[1] and mouse[1] < choice11[1] + choice11[3]: pygame.draw.rect(screen, red, choice11, 3) if lang == 0: screen.blit(settings, (440, 330)) if mouse[0] > choice20[0] and mouse[0] < choice20[0] + choice20[2]: if mouse[1] > choice20[1] and mouse[1] < choice20[1] + choice20[3]: pygame.draw.rect(screen, red, choice20, 3) for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONDOWN: settings() break return elif lang == 1: screen.blit(nastavitve, (440, 330)) if mouse[0] > choice21[0] and mouse[0] < choice21[0] + choice21[2]: if mouse[1] > choice21[1] and mouse[1] < choice21[1] + choice21[3]: pygame.draw.rect(screen, red, choice21, 3) for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONDOWN: settings() break return if lang == 0: screen.blit(izhod1, (440, 360)) if mouse[0] > choice30[0] and mouse[0] < choice[0] + choice30[2]: if mouse[1] > choice30[1] and mouse[1] < choice30[1] + choice30[3]: pygame.draw.rect(screen, red, choice30, 3) for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONDOWN: pygame.quit() elif lang == 1: screen.blit(izhod2, (440, 360)) if mouse[0] > choice31[0] and mouse[0] < choice31[0] + choice31[2]: if mouse[1] > choice31[1] and mouse[1] < choice31[1] + choice31[3]: pygame.draw.rect(screen, red, choice31, 3) for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONDOWN : run = False pygame.display.update() def settings(): title0 = font1.render('SETTINGS', 1, black) title1 = font1.render('NASTAVITVE', 1, black) screen.blit(background , (0, 0)) if lang == 0: screen.blit(title0, (440, 250)) elif lang == 1: screen.blit(title1, (440, 250)) pygame.display.update()Can anyone help me with my problem?