I'm trying to create a game where keys are randomly selected and appear on the screen, and the player has to click on them. How to implement a check for pressing the desired key ?
unic1=random.randint(0,9)
unic2=random.randint(0,9)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
if event.key == "pygame.K_"+ str(unic1):
x2+=10
unic1=random.randint(0,9)
elif event.key != "pygame.K_" + str(unic1):
x2-=10
unic1=random.randint(0,9)