[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Suggestion: make Rect use float coordinates



On Fri, 2005-04-15 at 11:27 +0300, Tomi Kyöstilä wrote:
> ATM I use a position variable as a workaround. I add the speed to 
> position[1] and then do rect.topleft = position.

Your solution to use an external floating point value is the best
solution. I always use floating values for the position of objects in
any nontrivial project.

The pygame Rect object was originally stored as an SDL_Rect internally.
Not too long ago that changed because SDL_Rect uses shorts, and the
pygame Rect now uses ints.

The main purpose of the Rect is to represent pixel areas on the screen,
which is still nicely handled by integers. I have also wanted to be able
to use the Rect as a floating point container for positions, but I think
I'd be happier with a cool 2D vector class to store my object positions.