I am not sure if it is my code, or my IDE issue. Vscode windows will always become unresponsive and frozen when it plays the following animation/code mid-way.
It wont complete the whole animation as it crashes at around
go("3", 255, 0, 0, 8)
The code are actually running fine in the background as the frame is still counting in the terminal.
I am curious as to how this can be fixed, is this software issue or my code was wrongly written that caused memory leak.
def go(t, x, y, z, s):
if FRAME_NUM == s*FPS:
txt = t
showtext = pygame.font.SysFont(None, int(WIDTH/12))
showtext = showtext.render(txt, True, (100,100,100))
screen.fill((x, y, z))
screen.blit(showtext, (int(WIDTH/8), int(WIDTH/8)))
def main():
pygame.init()
while True:
pygame.event.pump()
for event in pygame.event.get():
if event.type == QUIT:
pygame.display.quit()
pygame.quit()
exit()
for i in range(0, 20*FPS):
#screen.fill((0, 0, 0))
go("1", 255, 255, 255, 2)
go("2", 255, 255, 0, 4)
go("3", 255, 0, 0, 8)
go("4", 255, 255, 255, 12)
go("5", 255, 255, 0, 16)
pygame.display.update()
global FRAME_NUM
FRAME_NUM += 1
print(FRAME_NUM)
clock.tick(FPS)
pygame.display.quit()
pygame.quit()
exit()