I can create a turtle that will be in a window with the following code:
Turtle t1 = new Turtle(w,100,100);
If I want to know its coordinates, I can write:
int getX(w);
But when I have 2 turtles, t1 and t2, I don't know what to do if I want to know turtle1's X coordinates.
Turtle t1 = new Turtle(w,100,100);
Turtle t2 = new Turtle(w,200,100);
If I were to write int getX(w), which turtles X coordinate would I get? How do I write so I get t1s cordinate?
Use turtle.xcor()
it returns the x position.
Use turtle.ycor()
it returns the y position.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With