I am writing a running game in Pygame. Everything works good, but the gravity looks choppy and when I press the spacebar to jump, the player teleports to the position I want it to, then the gravity makes it go back down. Test this code out and edit it to make everything smooth please! There are no more dependencies other than Pygame required to run this. (also, dont just come to edit this question, actually give me an answer!)
import pygame
pygame.init()
win = pygame.display.set_mode((400,300))
pygame.display.set_caption("RUN! Reborn")
y = 128
yVel = 16
jumpVel = 128
isJump = False
run = True
while run:
pygame.time.delay(100)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE] and isJump == False:
isJump = True
y -= jumpVel
y = y + yVel
if y > 228:
y = 228
isJump = False
win.fill((31,247,250))
pygame.draw.rect(win, (0,0,0), (128,y,32,32))
pygame.draw.rect(win, (47,224,51), (0,260,400,40))
pygame.display.update()
pygame.quit()
#please don't steal this code.