I want to move an image in python/pygame, but it doesn't work, python doesn't even notice that the key is pressed. I found solutions and compared my code to others, but it still doesn't work... I'm very new to coding (started only this week) please correct my code
import pygame
pygame.init()
display_width = 800
display_height = 600
black = (0,0,0)
white = (255,255,255)
bright_red = (255,0,0)
bright_green = (0,255,0)
red = (200,0,0)
green = (0,200,0)
gameDisplay = pygame.display.set_mode((display_width,display_height))
smileImg = pygame.image.load('mouth.png')
clock = pygame.time.Clock()
def smile(x,y):
gameDisplay.blit(smileImg, (x,y))
x = (display_width * 0.45)
y = (display_height * 0.8)
go = 0
gameExit = False
while not gameExit:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_BACKSPACE:
go = -10
if event.type == pygame.KEYUP:
if event.key == pygame.K_BACKSPACE:
go = 0
y += go
gameDisplay.fill(white)
smile(x,y)
pygame.display.update()
clock.tick(60)
pygame.quit()
quit()