0

I'm making a button where when I click the button, a sound is played. The problem with this code is that the sound plays at a delayed speed (self.click_effect() is the sound method).

I'm aware that I've set the self.click_effect() not directly under the if statement as when I did, the sound plays multiple times instead of once (my game runs at 60 FPS).

Not sure where I should go from now.

def mouse_check(self): 
    mouse_pos = pygame.mouse.get_pos()
    if self.top_rect.collidepoint(mouse_pos):
        if pygame.mouse.get_pressed()[0]:
            self.delta_elevation = 0
            self.press = True
            
        else:
            self.delta_elevation = self.elevation
            
            if self.press == True:
                self.click_effect()
                print("check!")
                self.press = False
    else:
        self.top_colour =  self.top_colour
        self.delta_elevation = self.elevation
D_00
  • 1,312
  • 2
  • 11
  • 31
cat lat
  • 37
  • 3

0 Answers0