I am creating a game and I need to provide rect.x with a decimal number to control the players speed. But my player never ends up moving when going below 1. Is there anyway I can assign a decimal number to rect.x? I am using python 3.10.4 with spyder IDE on a windows 10 home computer. Any answer is very much appreciated.
Code:
vel = 0.5
userInput = pygame.key.get_pressed()
if userInput[pygame.K_LEFT]:
rect.x -= vel
if userInput[pygame.K_RIGHT]:
rect.x += vel
if userInput[pygame.K_UP]:
rect.y -= vel
if userInput[pygame.K_DOWN]:
rect.y += vel