import pygame
import sys
from pygame import *
from pygame.locals import RESIZABLE
pygame.init()
WINDOW_SIZE = (800, 600)
screen = pygame.display.set_mode(WINDOW_SIZE, RESIZABLE, 32)
player_img = pygame.image.load('ClipartKey_738895_adobespark.png')
player_X = 130
player_Y = 500
player_change_X=0
def player():
screen.blit(player_img, (player_X, player_Y))
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
sys.exit()
if event.type == KEYDOWN:
if event.key == K_RIGHT:
player_change_X = 0.3
if event.key == K_LEFT:
player_change_X = -0.3
if event.key == K_SPACE:
player_Y += 40
elif event.type == KEYUP:
if event.key == K_RIGHT:
player_change_X = 0
if event.key == K_LEFT:
player_change_X = 0
screen.fill((0, 200, 255))
player()
player_X += player_change_X
pygame.display.update()
I want to make the player jump approximately by 4y but not able to do so. Please tell me how can I do so and if telling any function please also tell what and how it does it as I'm new to pygame.