I am making a game in pygame and I want a picture to appear, only if the cursor is on it. Here is what I did:
while True:
clock.tick(FPS)
mx, my = pygame.mouse.get_pos()
darktower_rect = pygame.Rect(x, y, DARK_TOWER.get_width(), DARK_TOWER.get_height())
if darktower_rect.collidepoint((mx,my)):
WIN.blit(DARK_TOWERT, (x, y))
if click:
main()
for event in pygame.event.get():
if event.type==pygame.QUIT:
pygame.quit()
if event.type==pygame.MOUSEBUTTONDOWN:
if event.button==1:
click=True
pygame.display.update()
This works, but the problem is, that blit
keeps the picture there, and I want the picture to disappear, after the mouse is no longer on it.