I have been fiddling with this for hours, I am new to this stuff and for this one I can figure it out so any help would be much appreciated.
I have been trying to get my code to only detect 1 click when you click once. About 80% of the time this happens however occasionally it will click in an area 3-5 times and I was wondering how I could avoid that.
This is part of my code that I am struggling with:
for event in pygame.event.get():
state=pygame.key.get_pressed()
print (state)
if event.type == pygame.QUIT:
pygame.quit()
break
mouse=pygame.mouse.get_pos()
print (mouse)
if event.type == pygame.MOUSEBUTTONDOWN and 1015>mouse[0]>825 and 220>mouse[1]>160 and rand==1:
mouse= pygame.mouse.get_pos()
setDisplay.blit(boxz, (0,0))
pygame.display.update()
time.sleep(0.4)
if event.type == pygame.MOUSEBUTTONDOWN and 1235>mouse[0]>1045 and 220>mouse[1]>160 and rand==1:
setDisplay.blit(a2z, (0,0))
setDisplay.blit(zzz3, (800, 20))
pygame.display.update()
time.sleep(0.4)