What are you trying to achieve?:
- 2 circles presented on left or right side of screen. After 1 second, the left circle moves to the right, right moves to left.
- Once the circles reach the edge of the screen (+/-30, 0), I want them to switch directions. The left circle will now move to the left and vice versa.
What did you try to make it work?:
#beginning of experiment
t2 = core.Clock()
#beginning of routine
#color change
if Position == [-19.5, 0] and t >= 1 and not leftAnnuli.contains(mouse):
leftAnnuli.lineColor = [1,-0.5,-0.5] #red
elif Position == [-19.5, 0] and t >= 1 and leftAnnuli.contains(mouse):
leftAnnuli.lineColor = [-0.5,1,-0.5] #green
if Position == [19.5, 0] and t >= 1 and not rightAnnuli.contains(mouse):
rightAnnuli.lineColor = [1,-0.5,-0.5] #red
elif Position == [19.5, 0] and t >= 1 and rightAnnuli.contains(mouse):
rightAnnuli.lineColor = [-0.5,1,-0.5] #green
#beginning mvmt
initialMvmt = True
reverseMove = None
originMove = None
reset = False
#each frame
#beginning mvmt
if t > 1 and initialMvmt:
rightAnnuli.pos = [(19.5-(t-1)*5), 0]
leftAnnuli.pos = [(-19.5+(t-1)*5), 0]
if t <= 1:
mouse.setPos((0,0))
#changing directions, both extremes
if rightAnnuli.contains(-30, 0) and not reset:
t2.reset()
reverseMove = True
initialMvmt = False
reset = True
if reverseMove == True:
rightAnnuli.pos = [(-27+(time)*5), 0]
leftAnnuli.pos = [(27-(time)*5), 0]
if rightAnnuli.contains(30, 0) and reset:
t2.reset()
reverseMove = False
originMove = True
reset = False
if originMove == True:
rightAnnuli.pos = [(27-(time)*5), 0]
leftAnnuli.pos = [(-27+(time)*5), 0]
What specifically went wrong when you tried that?:
They change directions, though in a jarring manner (will disappear for a frame or two then reappear, might be my system only). The big issue: after the 3rd changing of direction (right circle hits the left end for second time), the circles switch. Since I have a randomized choice of the ‘correct’ circle for the subject to follow, this is an issue. The ‘correct’ circle, which is red, will switch places with the other circle (white in colour). I don’t know what causes this.