我正在编写一个程序,尽管我有一些基本包含相同值的变量,但它们通过if语句阻止了执行另一条if语句的方法。
if check_2.get() == "1":
if result_1 or result_1A or result_1B or result_1C or result_1D == True:
head = pygame.Rect(20, 20, 60, 60)
pygame.draw.rect(screen, (255, 50, 50), head)
elif result_1 or result_1A or result_1B or result_1C or result_1D == False:
pass
if result_2 or result_2A or result_2B or result_2C or result_2D == True:
head = pygame.Rect(80, 80, 60, 60)
pygame.draw.rect(screen, (255, 50, 50), head)
head = pygame.Rect(180, 80, 60, 60)
pygame.draw.rect(screen, (255, 50, 50), head)
elif result_2 or result_2A or result_2B or result_2C or result_2D == False:
pass
if result_3 or result_3A or result_3B or result_3C or result_3D == True:
head = pygame.Rect(80, 180, 60, 60)
pygame.draw.rect(screen, (255, 50, 50), head)
head_1 = pygame.Rect(180, 280, 60, 60)
pygame.draw.rect(screen, (255, 50, 50), head_1)
head_2 = pygame.Rect(130, 280, 60, 60)
pygame.draw.rect(screen, (255, 50, 50), head_2)
elif result_3 or result_3A or result_3B or result_3C or result_3D == False:
pass
else:
print("Sorry")
不要介意这些,它们很好。
例如,如果我只允许result_1为True .....,result_2和result_3变得不确定,因此它不允许我绘制单个矩形。希望得到一些帮助。