Re-drawing a line updating its orientation as mouse movement

Hi, I’m a newbie to psychopy and I’m planning to run an online experiment.
My experiment is simple; observers see a random dot motion, and report the direction of motion they saw by mouse.

My question is here in the response phase:
I’m trying to present a line which is re-drawn by the mouse movement in every frame until making a click so that the observers can see the orientation of line to report the direction they saw.
The line orientation is from 0 to 360 degree.
If observers decide to report a specific orientation of line, they click a mouse button to confirm their response.

I’m a new here so I’d like to make this experiment by builder.
Is it possible to make it by builder? Any comments will be vey helpful!
Thanks in advance.

Hi Meg,

I’m not very familiar with the draw component in the builder, but i think that what you want to achive can still be done in the builder with a little bit of coding.

My solution would be:

  • Create a “line” (a very tall and narrow rectangle)
  • Create a point (a very small circle) at the centre of the screen and of the line, the same color of the line so it is invisible
  • Set the orientation of the line as a variable to be updated every frame (e.g. $myOri)
  • Create a code component and place it at the top of the list of componets
  • In the “begin routine” tab set the orientation (myOri) you want the line to be at the beginning (like vertical, orizontal or even random)
  • In the “every frame” tab calculate the position of the mouse with mouse.getPos() when the mouse is clicked
  • With a little bit of geometry calculate the orientation the line should have to connect the mouse and the point in the middle and set myOri accordingly
  • Finally, you can have the routine end when a keyboard button is pressed and have the final myOri saved with thisExp.addData()

tandy

1 Like

Hi Tandy,

Thanks for your kind reply, and sorry for a little late response!
Thanks to your suggestion, I’ve almost done to make the experiment.
I didn’t know how much I could make with Builder and what I couldn’t make, but thanks to your suggestion, I figured out them.

Thanks again and hope you having great holiday!
Meg