Commits

César Bustíos  committed e474cc4

Blocking mouse events while waiting for delay (when boxes don't match)

  • Participants
  • Parent commits eb8650b

Comments (0)

Files changed (1)

File src/memory.py

 
                     # If your memory sucks, mark both as unrevealed
                     if logo1 != logo2:
+                        # Block mouse events for a while
+                        pygame.event.set_blocked(pygame.MOUSEBUTTONUP)
+                        pygame.event.set_blocked(pygame.MOUSEBUTTONDOWN)
+
+                        # Change revealed state to hide the boxes
                         pygame.time.delay(500)
                         board['revealed'][first_choice[0]][first_choice[1]] = False
                         board['revealed'][row][col] = False
+
+                        # Allow mouse events again
+                        pygame.event.set_allowed(pygame.MOUSEBUTTONUP)
+                        pygame.event.set_allowed(pygame.MOUSEBUTTONDOWN)
                     else:
                         # TODO: Animate matched logos or something?
                         pass