I am trying to make a clone of flappy bird to learn pygame and I'm a beginner. Just doing the basics, and I want the image to jump whenever the user presses space button or else the image keeps falling down. The problem I'm getting is that if I keep the space button pressed, it will keep flying upwards rather than just a single jump at a time. How do I fix this? (Someone explain the basic physics required to apply for the jump in flappy bird)
import pygame
pygame.init()
screen = pygame.display.set_mode((500,500))
c = pygame.image.load('cookie.png')
run = True
x,y = 50,50
while run:
screen.fill((255,255,255))
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE]:
y -= 1
else:
y += 0.2
screen.blit(c, (x,y))
pygame.display.update()
pygame.quit()