Conditional movement direction and distance with animation

OS (e.g. Win10): Win10/MacOS
PsychoPy version (e.g. 1.84.x): 3.0.3
What are you trying to achieve?:

I am trying to make a delay discounting experiment, in which after an individual chooses an option (between larger later and sooner smaller). At a start of each trial, an avatar (a triangle) would be placed between these two options, with the distance from each option representing a reward (see illustration below). So if individual chooses 10 dollars, triangle will start moving left and after a certain amount of time, will reach the left option and the trial will end. If an individual chooses 20 dollars, the triangle will start moving right.
I know how to animate stimuli, but I have no idea how to make the direction of movement conditional, as well as the choice of initial placing (i.e. making distance representative of delay).
Thank you for any input you can provide!
Illustration:

@agleontyev, you may want to define your start positions in your conditions file, and then modulate the x-axis position with a speed value. So, assuming you have a mouse called “mouse”, your boxes are polygons called “left” and “right”, and your triangle is called “marker”, set a column in your conditions file called startPos, and set your marker pos in the Builder component to [startPos, 0]. Then, in a code component:

# Start Routine
moveRight = False
moveLeft = False
moveSpeed = .001  # This is for norm units, you may want to change if using pix etc

# Each Frame
# Check if boxes are clicked
if mouse.isPressedIn(right):
    moveRight = True
    moveLeft = False
elif mouse.isPressedIn(left):
    moveLeft = True
    moveRight = False

# Set the marker to move
if moveRight:
    marker.setPos((marker.pos[0]+moveSpeed, 0))
elif moveLeft:
    marker.setPos((marker.pos[0]-moveSpeed, 0))
 
if right.contains(marker.pos) or left.contains(marker.pos):
    continueRoutine = False  # end routine if marker in box


Thank you so much! You are a savior!
Each second there is 60 frames, and each second the marker will move say, .001*60 = .06 of the screen distance?

Another question I have is how can I define that a person can only click once in a trial? Right now a participant can change the direction before the marker reaches the box. I want to make it unreversable in a given trial.

That’s right. To only allow one click, you could enter a flag to say whether or not a decision has been made:

# Start Routine
moveRight = False
moveLeft = False
moveSpeed = .001  # This is for norm units, you may want to change if using pix etc
decision = False  # Has a decision been made?

# Each Frame
# Check if boxes are clicked
if mouse.isPressedIn(right) and not decision:
    moveRight = True
    decision = True
elif mouse.isPressedIn(left) and not decision:
    moveLeft = True
    decision = True

# Set the marker to move
if moveRight:
    marker.setPos((marker.pos[0]+moveSpeed, 0))
elif moveLeft:
    marker.setPos((marker.pos[0]-moveSpeed, 0))
 
if right.contains(marker.pos) or left.contains(marker.pos):
    continueRoutine = False  # end routine if marker in box