Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+13 votes

I made the turtles follow the mouse but I wanted to make the turtles follow at a distance . How do I do that?

asked in CSC 150 January201920 by (1 point)

3 Answers

+6 votes

You can do setxy (mouse-xcor + 1) (mouse-ycor +1) to make it stay a bit further from the mouse.

answered by (1 point)
+4 votes

Try something like this:

to go
  ask turtles [
    if (distancexy mouse-xcor mouse-ycor) > 4 [ 
      facexy mouse-xcor  mouse-ycor
      right random 180  ; a bit of random variation helps
      left random 180   ; the turtles separate from each other
      forward 0.1
    ]
  ]
end    
answered by (1.9k points)
+2 votes

You can use facexy (mouse-xcor) (mouse-ycor + 1)

answered by (1 point)
...