Не понимаю как реализовать движение по полю в python библиотеки pygame кнопками wasd
import pygame
import funcs
pygame.init()
pygame.display.set_caption('hello')
background = pygame.image.load('img/background.png')
person = pygame.image.load('img/person.png')
display_w = 500
display_h = 500
loc_x = 100
loc_y = 100
game_exit = False
clock = pygame.time.Clock()
game_display = pygame.display.set_mode((display_w, display_h))
game_display.blit(background, (0, 0))
game_display.blit(person, (loc_x, loc_y))
class Inventory:
key = False
def process_keyboard(event):
global loc_x, loc_y
if event.type == pygame.event.get:
if event.key == pygame.KeyW:
loc_y += 25
if event.type == pygame.KeyS:
loc_y -= 25
if event.type == pygame.KeyA:
loc_x -= 25
if event.type == pygame.KeyD:
loc_x += 25
def game_loop(update_time):
global game_exit
while not game_exit:
for event in pygame.event.get():
print(event)
process_keyboard(event)
if event.type == pygame.QUIT:
game_exit = True
quit()
pygame.display.update()
game_loop(30)
pygame.quit()
quit()