DeprecationWarning: an integer is required (got type float). Помогите пожалйста

Я решил написать игру и застрял на моменте где не отображались кадры и спрайты при передвижении в право или в лево . Выдаёт такую ошибку:

D:/GAMES_2/GAme#1/Cubes Game.py:44: 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.
  win.blit(playerStand, (x, y))
D:/GAMES_2/GAme#1/Cubes Game.py:41: 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.
  win.blit(walkRight[animCount // 5], (x, y))
D:/GAMES_2/GAme#1/Cubes Game.py:38: 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.
  win.blit(walkLeft[animCount // 5], (x, y))

Я не знаю как решить данную проблему,буду очень благодарен всем кто согласиться помочь! Мой Код:

import pygame
from turtle import width as t_width

pygame.init()
win =  pygame.display.set_mode((500, 500))

pygame.display.set_caption("Cubes")
walkRight = [pygame.image.load('right_1.png'), pygame.image.load('right_2.png'), pygame.image.load('right_3.png'), pygame.image.load('right_4.png'), pygame.image.load('right_5.png'), pygame.image.load('right_6.png')]

walkLeft = [pygame.image.load('left_1.png'), pygame.image.load('left_2.png'), pygame.image.load('left_3.png'), pygame.image.load('left_4.png'), pygame.image.load('left_5.png'), pygame.image.load('left_6.png')]

bg = pygame.image.load('bg.png')
playerStand = pygame.image.load('player.png')

clock = pygame.time.Clock()
x = 50
y = 250
width = 40
height = 60
speed = 5

isJump = False
JumpCount = 10

left = False
right = False
animCount = 0

def drawWindow():
    global animCount
    win.blit(bg, (0, 0))


    if animCount + 1 >=30:
        animCount = 0

    if left:
        win.blit(walkLeft[animCount // 5], (x, y))
        animCount += 1
    elif right:
        win.blit(walkRight[animCount // 5], (x, y))
        animCount += 1
    else:
        win.blit(playerStand, (x, y))
        pygame.display.update()


run = True
while run:
    clock.tick(30)

    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 > 10:
        x -= speed
        left = True
        right = False
    elif keys[pygame.K_RIGHT] and x < 500 - width - 10:
        x += speed
        left = False
        right = True
    else:
        left = False
        right = False
        animCount = 0

    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




    if keys[pygame.K_ESCAPE]:
            run = False
    drawWindow()

Ответы (1 шт):

Автор решения: CrazyElf

У вас не ошибка, а предупреждение, работоспособность программы от этого не зависит. Думаю, вот этого будет достаточно, чтобы предупреждение исчезло (я поменял деление на целочисленное):

       if JumpCount < 0:
            y += (JumpCount ** 2) // 2
        else:
            y -= (JumpCount ** 2) // 2

Но если вам нужна бОльшая точность значения y при расчётах, то надо наоборот тогда при вызове win.blit везде приводить y к целому - int(y), а в вышеприведённом фрагменте оставить как было.

→ Ссылка