current position:Home>Question about pygame

Question about pygame

2022-08-06 19:02:30CSDN Q&A

While continuously accepting commands from the console with input, while drawing on the pygame window according to the command, it sounds simple, but there are too many problems
First pygame needs

 while True: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() pygame.display.update()

On the other hand I need

 while True: com = input('>') if 'add' in com: pygame.draw.circle(screen, (0, 0, 0), ( 250, 250), 3)

Adding the input directly to the while True loop outside pygame.display.update() will cause the pygame page to freeze, the multi-thread attempt fails, and the multi-process fails: EOF when reading a line

Would you like to write a picture for me?

copyright notice
author[CSDN Q&A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/218/202207310344169210.html

Random recommended