However, on some occasions the pacman doesn't respond to the key press, presumably because it was made at exactly a loop-point.
You probably won't be able to avoid this completely, however with the right timing, these occasions should be rare.
So, my question would be: Is there a way that a pacman-figure is moving on its own, and a participant can intervene this movement by changing directions via key presses?
You'll want to do something like this:
<defaults>
/ windowsize = (800px, 600px)
</defaults>
<values>
/ h = 50%
/ v = 50%
/ step = 2%
/ direction = 205
</values>
<shape mydot>
/ shape = circle
/ size = (25px,25px)
/ hposition = values.h
/ vposition = values.v
/ color = (white)
/ erase = false
</shape>
<shape mybackground>
/ shape = rectangle
/ size = (100%,100%)
/ color = (black)
/ erase = false
</shape>
<trial mytrial>
/ ontrialend = [if(trial.mytrial.response!=0)values.direction=trial.mytrial.response]
/ ontrialend = [if(values.direction==200)values.v=values.v-values.step]
/ ontrialend = [if(values.direction==208)values.v=values.v+values.step]
/ ontrialend = [if(values.direction==205)values.h=values.h+values.step]
/ ontrialend = [if(values.direction==203)values.h=values.h-values.step]
/ ontrialend = [if(values.h<0)values.h=100%]
/ ontrialend = [if(values.h>100%)values.h=0%]
/ ontrialend = [if(values.v<0)values.v=100%]
/ ontrialend = [if(values.v>100%)values.v=0%]
/ stimulusframes = [1=mybackground, mydot]
/ validresponse = (0,200,203,205,208)
/ trialduration = 300
/ branch = [trial.mytrial]
</trial>
<block myblock>
/ trials = [1=mytrial]
</block>
Regards,
~Dave