Answer the question
In order to leave comments, you need to log in
Error in code: AttributeError: 'NoneType' object has no attribute 'fill'?
import pygame
import time
pygame.init()
win = pygame.display.set_caption("123")
x = 50
y = 50
widht = 40
height = 60
speed = 5
run = True
while run:
pygame.time.delay(100)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
x -= speed
if keys[pygame. K_RIGHT]:
x -= speed
if keys[pygame.K_UP]:
x -= speed
if keys[pygame.K_DOWN]:
x -= speed
win.fill((0,0,0))
pygame.draw.rect(win, (0,0,255), (x,y,height))
pygame.display.update()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question