[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Event polling, is there a standard trick to combine ...



Thanks... Yes sort of it wouldn't normally be worth it.
I think it is though if user is dragging a window around inside a
viewport... changing the scroll pos... then
if the code gets behind in reading the stream of mousemove events the screen
jumps about... surely I can
shortcut to the current relative position... (not abs position I think,
which won't work outside the application window, unlike
then drag which will...)


Frank Raiser wrote:

> On Sun, Sep 09, 2001 at 07:18:11PM +0100, Peter Goode wrote:
> > Anyone written anything which combines (e.g.) MOUSEMOTION events from
> > the queue...
> > So if there are several you can grab them all as one and deal with
> > that...
> > Might help with scrolling catchup...
> You mean like adding up the relative movements? I don't think there's
> something like that in the PCR and haven't seen it elsewhere.. but it
> shouldn't be hard to write that yourself.
> Untested code to sum up relative mouse movements:
>
> motions = pygame.event.get([MOUSEMOTION])
>
> x = reduce(lambda x,y: x+y, map(lambda x: x.rel[0],motions))
> y = reduce(lambda x,y: x+y, map(lambda x: x.rel[1],motions))
>
> This should give you the amount of totally moved pixels in (x,y).
>
> Of course there's got to be some better code for that.. I just made that
> one up fast.. and I also don't believe it's worth it anyways.. as it'll
> be certainly faster to save the old mouse position and when you check it
> again just use pygame.mouse.get_pos() and calculate the difference by
> a simple subtraction.. much easier, cleaner and faster.
>
> --
> Raiser, Frank aka CrashChaos
> IRC: 141.30.225.9:6667 #United-Programmers
>
> "Sire, The citizens are revolting!",
> "I know... that's why I live in this castle..."
> ____________________________________
> pygame mailing list
> pygame-users@seul.org
> http://pygame.seul.org

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org