I'm working on creating an aim trainer using pygame. Here's the code that is supposed to check when I hit the target:
if event.type == pygame.MOUSEBUTTONDOWN:
mx,my = pygame.mouse.get_pos()
print(mx, my)
if x <= mx <= (x + targetwidth):
if y <= my <= (y +targetheight):
targetcount = 0
del target
existingTarget = False
hit +=1
print("you hit a target!")
pygame.display.update()
break
x and y is the postion of the target(randomly generated as soon as a new one is needed)
But even if I click onto the targets, nothing happens. How do I handle clicks on my pygame sprites correctly? Thanks in advance.