W
W
wertlim2020-07-08 11:42:35
Python
wertlim, 2020-07-08 11:42:35

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()


Error:
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
game.py:61: DeprecationWarning: an integer is required (got type float). Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
pygame.draw.rect(win, (128, 0, 128), (x, y, width, height))

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question