import pygame
def main():
while True:
print(window_size) # works for some reason
print(window_flag) # works for some reason
print(color_flag) # nope python says no
print(current_fps) # python says no
print(previous_fps) # python says no
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
if color_flag:
... # s.o format issue
if __name__ == "__main__":
window_size = (500, 500)
window_flag = pygame.RESIZABLE
# the rejected trio
color_flag = 0
current_fps = 0.0
previous_fps = 0.0
# :(
window = pygame.display.set_mode(window_size, window_flag)
clock = pygame.time.Clock()
main()
When I attempt to print the color_key
and subsequent variables I encounter an UnboundLocalError
which confuses me, since window_size
and window_flag
are output without issue. Could someone provide insight into why this is the case?