Seems like an interesting problem. Thanks for everyone for the examples. It took me a bit to realize what they did since I’m on my phone.
Here’s my event based solution. The first part is just for input, the last event is the meat.
First it skips the dot the cursor is on.
Next it picks all the dots in a cone in the direction pressed.
Then it utilizes “for each ordered” to sort them by distance. It would be the same as “pick closest” but it also adds a fraction of the perpendicular distance so it prefers the dots closer to the direction pressed as opposed to just one of them when they are all the same distance away.
variable joyx=0
variable joyy=0
variable dir=0
variable move=false
every tick
-- set move to true
-- set joyx to 0
-- set joyy to 0
on left pressed
-- add -1 to joyx
on right pressed
-- add 1 to joyx
on up pressed
-- add -1 to joyy
on down pressed
-- add 1 to joyy
compare: abs(joyx)+abs(joyy)=0
-- set move to false
else
-- set dir to angle(0,0,joyx,joyy)
move is true
pick dot by evaluate: dot.x<>cursor.x & dot.y<>cursor.y
pick dot by evaluate: 45>anglediff(dir, angle(cursor.x, cursor.y, dot.x, dot.y))
for each dot ordered by distance(cursor.x, cursor.y, dot.x, dot.y) + abs(cos(dir+90)*(dot.x-cursor.x)+sin(dir+90)*(dot.y-cursor.y))/1000 ascending
-- stop loop
-- cursor: set position to dot