Hi,

I just took a short look. As I see you call my_dispatch_events() in your 
event loop. Each time it registers a new set of event observers that all 
use the same event object to store the results.

The problem here is that it is possible that more than 1 event arrives in 1 
iteration of the loop. In that case the event object is overwritten with 
the last event. Also it is not necessary to keep registering new observers. 
This will probably in the end cause some kind of memory and resource leak.

It is better to have the observers registered only once and then have them 
store each event in a Queue (or list). Then in your loop process the 
contents of the Queue before going to the next iteration.

Rob

Op woensdag 25 februari 2015 17:33:25 UTC+1 schreef Jose Luis Da:
>
> Hi all, 
>
> I am using pyglet to develop a series of visual stimuli. I have some 
> problems with my code, could you help me understand what I am doing wrong?
>
> I have attached a part of the code I am using, the main file is called 
> "150121_Plaid_v19", and "rlabs_libutils" is a library of some functions, 
> one of which I will explain next.
> In lines 190 - 258 I have the stimulus loop (or game loop) and for each 
> iteration I need to retrieve the subject's input and save it in an array. 
> In order to do that, I use the function 'my_dispatch_events', which I call 
> in line 204 with the pyglet window and an instance of a class called 
> LastEvent() that I defined.
>
> With this method, I lose some of the data. Could you help me understand 
> what would be a good method of retrieving input events and saving them for 
> each iteration of the game loop, while using as few global variables as 
> possible (I would like to keep the pyglet window instance as a local 
> variable)?.
>
> Thank you very much for your attention,
> jl
>

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to