Answer the question
In order to leave comments, you need to log in
The code doesn't work, the error in the description used only the pygame library, help me?
import pygame
pygame.init()
win = pygame.display.set_mode((1000, 700))
pygame.display.set_caption("GAME")
x = 500
y = 620
width = 50
height = 65
speed = 10
isJump = False
jumpCount = 10
run = True
while run:
pygame.time.delay(50)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT] and x > 5:
x -= speed
if keys[pygame.K_RIGHT] and x < 1000 - width - 5:
x += speed
if not(isJump):
if keys[pygame.K_SPACE]:
isJump = True
else:
if jumpCount >= -10:
if jumpCount < 0:
y += (jumpCount ** 2) / 2
else:
y -= (jumpCount ** 2) / 2
jumpCount -= 1
else:
isJump = False
JumpCount = 10
win.fill((0,0,0))
pygame.draw.rect(win, (128, 0, 128), (x, y, width, height))
pygame.display.update()
pygame.quit()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question