I am trying to make my stimulus move constantly from the left to the right and move up and down if certain buttons are pressed.
The position of the stimulus is set every frame by (pos_x, pos_y).
In the code component, I have
pos_x = -0.5 # the initial x coordinates pos_y = 0 # the initial y coordinates plus_y = 0.03 minus_y = -0.03
pos_x = pos_x + 0.001 # this makes the stimulus constantly move from the left to the right if warm.keys == "up": pos_y = pos_y + plus_y # if the UP button is pressed move the stimulus up elif warm.keys == "down": pos_y = pos_y + minus_y # if the DOWN button is pressed move the stimulus down else: pos_y = pos_y
It all works perfectly except the stimulus doesn’t stop moving after pressing the UP or DOWN button. I’d like it to just bounce 0.03 units up or down if the button was pressed. Instead, pressing the button makes it constantly moving up or down until the opposite button is pressed (then it starts moving in the opposite direction).
I’m not good at coding and I think I miss something very simple. Would be happy to get some advice!
P.S. I also want my stimulus to leave a line behind it (some sort of a footprint). May be some of you know how to do it?