I am working on a program and i need to switch through different loops. this works thought when i try to switch back to the previous loop i crashes.
Any suggestions?
P.S. the bellow are examples
e.g. Function = Home
(change loop)
Function = txtbox
(change loop)
Function = Home (Crashes here)
import pygame, sys, time, random
from pygame.locals import *
import math
import sys
import os
# set up pygame
pygame.init()
# set up the window
WINDOWWIDTH = 1200
WINDOWHEIGHT = 650
windowSurface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT), 1, 32)
pygame.display.set_caption("Mango")
Function = "Home"
font = pygame.font.SysFont("Fonts", 30)
#colors
TEXTCOLOR = (255, 255, 255)
TEXTCOLORS = (255, 0, 0)
# run the game loop
while Function == "Home":
# check for the QUIT event
events = pygame.event.get()
for event in events:
if event.type == QUIT:
pygame.quit()
sys.exit()
elif event.type == pygame.MOUSEBUTTONUP:
Function = "txtbox"
break
pygame.display.flip()
while Function == "txtbox":
events = pygame.event.get()
# process other events
for event in events:
if event.type == pygame.MOUSEBUTTONUP:
Function = "Home"
break
pygame.display.flip()