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

RE: [pygame] Speed of mouse position capture



> Kamilche wrote:
> > Brian wrote:
> > So in my Pygame app, I am trying to create a system where the user 
> > interacts with the game by drawing glyphs on the screen 
> with the mouse 
> > - for example, drawing a small circle around an enemy with 
> the mouse 
> > might mean 'zap a Sleep spell at them'.
> > 
> > I am encountering one difficulty, which is that the speed of mouse 
> > position capture seems quite slow. I had expected that the 
> app would 
> > receive a MOUSEMOTION event every time the mouse shifted to a new 
> > pixel, and that connecting up the locations of these MOUSEMOTION 
> > events would give an almost exact representation of the path of the 
> > mouth across the screen. However, what happens in practice 
> is that, if 
> > the mouse is moving fast, consecutive MOUSEMOTION events can be 
> > separated by more than 20 pixels. This makes it very hard 
> to interpret 
> > the path of the mouse with enough precision - it ends up 
> divided into 
> > a small number of long line segments.
> > 
> > Is there a way to make Pygame sample the position of the mouse more 
> > often?
> > 
> > [snip]
>
> If you're on a Windows box, try using the DirectX engine. I 
> notice that that engine DOES capture every mouse position 
> change, and I have to throw away all but the first on every 
> pass through the loop, otherwise my game goes too slow. Using 
> the WINDIB engine, it throws away positions, and I experience 
> missing positions, as you mentioned.
> 
> For me, that's desired behavior. For you, you could try 
> interpolating the missing values if you absolutely must have them.

My development box is on Windows. I will try using directX - is the
default windib? (If so, why, as a matter of interest?)

I think the way to do this is via 
os.environ['SDL_VIDEODRIVER'] = 'directx'
before calling pygame.display.init() - is that correct?

This won't solve the problem for end users running other OS, but I
suspect end users' machines would typically be running faster than mine
(given that I am in debug mode) so it may not be a big issue.

Brian
"The information contained in this transmission is confidential. It is intended for the named address only. If you are not the named address you may not copy, distribute or take any action in reliance upon this transmission"