Pygame doesn't let me use float for rect.move, but I need it
Since pygame.Rect
is supposed to represent an area on the screen, a pygame.Rect
object can only store integral data:
The coordinates for Rect objects are all integers. [...]
If you want to store object positions with floating point accuracy, you have to store the location of the object in separate variables respectively attributes and to synchronize the pygame.Rect
object. round
the coordinates and assign it to the location (e.g. .topleft
) of the rectangle:
x, y = # floating point coordinates
rect.topleft = round(x), round(y)