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

Re: [pygame] broken links, event handling vs "getting directly" and screen refresh



On Mon, Feb 04, 2002 at 09:11:48AM -0800, Pete Shinners wrote:
> > 2) In http://pygame.org/docs/tut/newbieguide.html, it says that using
> > the event system isn't always the best way to go.  In my case, it's ok
> > if I miss a mouse click once in a while, but I don't want latency
> > creeping in, so I initially decided to avoid the event system.  However,
> > I'm noticing that if I obscure my game window with another briefly, I
> > don't get window refresh until I redraw the whole window.  Would this
> > problem be easier to solve if I were using the event system?  That is,
> > is there a "time to redraw the whole screen now" event?
> 
> it sounds like you've got the right idea for your situation. in games 
> that don't use the event system, there is still one function you will 
> need from the event module.
> 
> pygame.event.pump()
> http://www.pygame.org/docs/ref/pygame_event.html#pump
> 
> this function doesn't return anything, but it does allow pygame a chance 
> to talk with the window manager and environment. it does things like 
> make sure input devices (like joysticks) are up to date, but doesn't 
> generate any events for them.
> 
> and here's the good news for you...
> one important thing that happens in this call, pygame finds out if the 
> window needs to be repainted in any areas. if so, it automatically 
> remembers what should be drawn there and does the repainting for you.
> 
> usually you just call the pygame.event.pump() function once per frame,
> this should take care of business for you. on some platforms it is more 
> important to call the pump(), since it handles a bit more coordination 
> with the system (besides just redraws).

Thanks for your comments, both of you.

If I use a thread that does nothing but update the screen from a few
variables, and another thread that updates those variables and interacts
with my subprocess, do I need to wrap a semaphore around those common
variables?  Or does python's GIL (global interpreter lock) eliminate the
need for most coherency of concurrency stuff in python?  I know I'd
need a semaphore or something in C...

-- 
Dan Stromberg                                               UCI/NACS/DCS

PGP signature