Cześć otóż zrobiłem najprostszy kod ktory brzmi tak
import pygame, sys
pygame.init()
print(pygame.version)
screen = pygame.display.set_mode((1270, 720))
box = pygame.Rect(10, 10, 50, 50)
while True:
# Handle events
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit(0)
elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
sys.exit(0)
# Checking inputs
if pygame.key.get_pressed()[pygame.K_d]:
box.x += 1
if pygame.key.get_pressed()[pygame.K_s]:
box.y += 1
if pygame.key.get_pressed()[pygame.K_w]:
box.y -= 1
if pygame.key.get_pressed()[pygame.K_a]:
box.x -= 1
# Drawing
screen.fill((0, 0, 0))
pygame.draw.rect(screen, (0, 150, 255), pygame.Rect(10, 10, 50, 50))
pygame.display.flip()
czemu mi nie działa przesuwanie tego kwadrata a dokładnie to :
Checking inputs
if pygame.key.get_pressed()[pygame.K_d]:
box.x += 1
if pygame.key.get_pressed()[pygame.K_s]:
box.y += 1
if pygame.key.get_pressed()[pygame.K_w]:
box.y -= 1
if pygame.key.get_pressed()[pygame.K_a]:
box.x -= 1
nic sie nie dzieje