[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Suggestion: make Rect use float coordinates
- To: pygame-users@xxxxxxxx
- Subject: [pygame] Suggestion: make Rect use float coordinates
- From: Tomi Kyöstilä <tomi.kyostila@xxxxxxxxx>
- Date: Fri, 15 Apr 2005 11:27:35 +0300
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Fri, 15 Apr 2005 04:28:36 -0400
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:user-agent:x-accept-language:mime-version:to:subject:content-type:content-transfer-encoding; b=fPKBWONpLKSmJzmCvxyToy2ZYFaRPtHbKNUvXjbNCsf5oQbxzAmUvXED6f1n8uMTZXtLi9OPC13H/jmf5CcqcXetCodqEI7scs8DCXSRRE5wE5l9eDqbGcZFTDcaNJKTAnav/XG6AEcCVFVcQzU29Nh0GO8m+PVjSe2ZN1rLp3M=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
- User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)
Hello,
I just got pygame yesterday to see what's it like and what can I do with
it. I started a tetris-like game project to see pygame's features and such.
I made a tetris block which has a rect and a speed variable. On every
step I do rect.move_ip(0, speed), but I noticed that if the speed is 1,
the block moves too fast, so I tried 0.1. The block didn't move at all.
Then I tested different values; 0.5: nope, 0.9: nope, 1: moved, but too
fast as stated before. When I tried a value of 1.9, it was surprising.
It moved at the same speed as with a value of 1, so with my amazing
deduction skill (;)) I deduced that move and move_ip floored the value
to an integer.
On the IRC channel antont thought that the value would be needed as an
integer in some other place in pygame (he pointed out blitting as an
example), so that would be why it's stored as an integer. If that's the
case, IMHO the value should be floored (or rounded?) only where needed
(in the blit method in this case). I don't know how it would affect the
performance of blitting if it's done there, any info on this?
ATM I use a position variable as a workaround. I add the speed to
position[1] and then do rect.topleft = position. So if the speed was
0.1, the rect's position stays the same for 10 steps (due to the
flooring) and only then move 1 pixel. The workaround isn't too
complicated, but this would be a nice change in pygame if it doesn't
affect it's performance too much(?).
I haven't found other reasons why it is like it is, but it's very
possible that I haven't thought of something, so if you have any ideas
or opinions on the matter, please reply.
- dOb