Почему мое окно Pygame зависает при отображении этой графики? - PullRequest
0 голосов
/ 11 января 2020

Сейчас я нахожусь на последнем этапе проекта, в который я вложил много времени.

Это игра-симон. В основном у меня есть список, который добавляет случайное число к нему каждый раунд (1 число для первого раунда, 2 для раунда 2 и т. Д. c). так что к 8 раунду у меня есть 8 цветов, которые вспениваются sh на полсекунды, а затем исчезают. Это заставляет окно не отвечать. Есть идеи почему?

#If a click occurs
     if main == True:
            if other == True:
                if mousex >= 500 and mousex <= 600 and mousey >= 0 and mousey <= 50:
#This isnt needed
                    playerchoicelist = []
#Random num
                    randomnum = random.randint(1,4)
#Adds it to simon list
                    addtosimons()

                    for i in range (0, roundnum):
#If its 1, flashes light red square, then normal colour again etc.
                        if simonslist[i] == 1:
                            pygame.display.update()
                            pygame.draw.rect(screen, REDLIGHT, [200, 0, 400, 375])
                            pygame.draw.rect(screen, (50, 50, 50), [550, 0, 100, 50])
                            screen.blit (startroundtext,
                       (600 - startroundtext.get_width() // 2, 25 - startroundtext.get_height()//2))
                            pygame.display.update()
                            time.sleep(1)
                            pygame.draw.rect(screen, RED, [200, 0, 400, 375])
                            pygame.display.update()
                            other = False
                            other = True
                        if simonslist[i] == 2:
                            pygame.display.update()
                            pygame.draw.rect(screen, BLUELIGHT, [600, 0, 400, 375])
                            pygame.draw.rect(screen, (50, 50, 50), [550, 0, 100, 50])
                            screen.blit (startroundtext,
                       (600 - startroundtext.get_width() // 2, 25 - startroundtext.get_height()//2))
                            pygame.display.update()
                            time.sleep(1)
                            pygame.draw.rect(screen, BLUE, [600, 0, 400, 375])
                            pygame.display.update()
                            other = False
                            other = True
                        if simonslist[i] == 3:
                            pygame.display.update()
                            pygame.draw.rect(screen, GREENLIGHT, [200, 375, 400, 375])
                            pygame.draw.rect(screen, (50, 50, 50), [550, 0, 100, 50])
                            screen.blit (startroundtext,
                       (600 - startroundtext.get_width() // 2, 25 - startroundtext.get_height()//2))
                            pygame.display.update()
                            time.sleep(1)
                            pygame.draw.rect(screen, GREEN, [200, 375, 400, 375])
                            pygame.display.update()
                            other = False
                            other = True
                        if simonslist[i] == 4:
                            pygame.display.update()
                            pygame.draw.rect(screen, YELLOWLIGHT, [600, 375, 400, 375])
                            pygame.draw.rect(screen, (50, 50, 50), [550, 0, 100, 50])
                            screen.blit (startroundtext,
                      (600 - startroundtext.get_width() // 2, 25 - startroundtext.get_height()//2))
                            pygame.display.update()
                            time.sleep(1)
                            pygame.draw.rect(screen, YELLOW, [600, 375, 400, 375])
                            pygame.display.update()
                            other = False
                            other = True
                    addroundnum()
...