I am a newbie in Pygame (I use many libraries in python) There is a severe problem I face that is My pygame window is not responding I don't know why but this is happening every time I run the code.
here is the code:
import pygame
pygame.init()
win = pygame.display.set_mode((500,500))
pygame.display.set_caption("First Game")
x = 50
y = 50
width = 20
height = 60
vel = 5
x1 = 100
y1 = 100
width1 = 20
height1 = 60
vel1 = 5
run = True
while run:
pygame.time.delay(100)
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT] and x > vel:
x -= vel
if keys[pygame.K_RIGHT] and x < 245 - vel - width:
x += vel
if keys[pygame.K_UP] and y > vel :
y -= vel
if keys[pygame.K_DOWN] and y < 500 - height - vel:
y += vel
win.fill((255,255,255)) # Fills the screen with black
pygame.draw.circle(win , (255,0,0), (x,y), width)
pygame.draw.circle(win , (255,0,0), (x1,y1), width)
pygame.draw.rect(win, (0,0,0), (245, 0, 20, 500))
pygame.display.update()
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.quit()
Could you just please help to deal wit this problem.