1
I have serious problems in being able to build a functional module in which I have to use more than 1 while loop, because the program stops running.
Especially when I use modules like pygame and Tkinter, where my goal is to build a game, but I need to use more than 1 while loop, only if I run it stops working. In this situation I intend to run two while loops at the same time, but the window fails to respond. Why?
----------------------------#######--------------------------------------
Also I did not understand why my while loop does not cease to exist when I turn the variable 'playing' True? In this situation I just want to run a while loop at a time, the switch off of the while loop is when the 'playing' variable becomes True. Here’s the code:
playing = False
def play():
playing = True
def gameloop():
...
play()
while not playing:
gameloop()
while playing:
gameDisplay.fill(black)
pygame.display.update()
clock.tick(15)
The problem is that the second while loop does not run and the first one does not stop running when I call the play() function, even if it declares the global 'playing' variable. Why?
Using python 3.5.0 with Windows 10
I see no reason for windows not responding when I run more than one while loop, because with other people’s pc works perfectly. The problem will be from my pc?
What do you mean, "it stops working"? Describe in more detail the observed behavior.
– Pablo Almeida
Do you want to leave the two loops running together? Or the
while
below should only be started whenplaying
fortrue
? Describe it better as @Pabloalmeida says.– Christian Felipe
@Pabloalmeida how I am working with Tkinter the window stops working('does not answer')
– Inês Barata Feio Borges
@Christianfelipe Yes I want both loops at the same time, but only in the second situation. And the bass while should only be started when playing for True
– Inês Barata Feio Borges
But in your logic, if the
playing
for True the top while ends, so you’ll only have one while running anyway.– Christian Felipe
@Christianfelipe because when I run the program and turn the variable 'playing' True o while from above does not stop running and while from below does not start running
– Inês Barata Feio Borges