Making a basic game and im trying to get my character to jump when space is pressed
I have a simulated gravity that pulls it down when space is released
but when i push space down it goes up and doesnt stop
i want it to only goo up for like 1 second then go back down
Here is my key press handling code snippet:
key = pygame.key.get_pressed()
if key[pygame.K_LEFT]:
self.rect.x -= 30
if key[pygame.K_RIGHT]:
self.rect.x += 30
if key[pygame.K_SPACE]:
self.rect.y += -20
if key[pygame.K_SPACE] == False:
self.rect.y += 20
like i said this code makes the sprite go up when space is pressed and down when space is released but when it is pressed i want it to wait one second then make the sprite go back down even if the space bar is still down
Please help!!
thank you