i want to make a sprite and his rect disapear by pressing a key and reapear them by pressing the same key. but when i hold the key it disapear and reapear. im using pygame.key.get_pressed() so it's obvious why it does this, i just want to set a timer or something stoping the possibility of using the same key in the next couple milisecs.
def update(self):
keys = pygame.key.get_pressed()
if keys[pygame.key.key_code(self.letre)]:
if self.compteur == 0:
self.rect = pygame.Rect(-500,-500,-500,-500)
self.compteur = 1
elif self.compteur == 1:
self.rect = self.image.get_rect(topleft = self.pos)
self.compteur = 0