pygame.display.update doesn't show the rect moving

260 views Asked by At

I am a newbie about pygame, and my English is very poor.

I want to know why my code can't run as an animation without event.get().

import pygame
pygame.init()
screen = pygame.display.set_mode((500, 400))
pygame.display.set_caption('test')
i = 1
while i < 100:
    i += 1

    screen.fill((200, 200, 200))
    rect = pygame.Rect(1 + i, 1 + i, 50, 50)
    pygame.draw.rect(screen, (5, 5, 5), rect)
    # pygame.event.get() # if add this , it works

    pygame.display.flip()
0

There are 0 answers