Answer the question
In order to leave comments, you need to log in
How to create a loop in which the value of the second if will be executed only if the first if is executed?
That is, I want the second condition to be fulfilled only if the green light is on, that is, a green square is displayed, otherwise it does not work. I can’t do it yet, everything in the loop returns as it was and the second condition does not make sense, after the first Disabled = False, the False-True loop goes on and everything goes around, as a result, it works as it should for the first time and then True all the time
Disabled = False
for car in cars:
if Disabled == False and (car.rect.y+75) == y :
pygame.draw.rect(DISPLAY, GREEN, 10,40)
Disabled = True
elif Disabled == True and (car.rect.y+75)+100 == y :
car.rect.y += 75
Disabled = False
Answer the question
In order to leave comments, you need to log in
I am not familiar with Python, unfortunately, but in any language it is done like this:
while(){
if(Условие 1){
if(Условие 2){
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question