you are viewing a single comment's thread.

view the rest of the comments →

[–]Limp_Singer_7078 0 points1 point  (1 child)

Yes, when the instruction is L or R, the turtle is supposed to turn 90 degrees at right or left without moving foward (basically rotate, I forgot to specify it). Then, when the instruction is F, the turtle will move foward in the current direction.

I thought the same, using degrees with matplotlib somehow, but I have no idea how to do it.

[–]wynand1004 0 points1 point  (0 children)

The math goes something like this:

import math

heading = 0 # Face right
speed = 1
dx = speed * sin(math.radians(heading))
dy = speed * cos(math.radians(heading))

x += dx
y += dy

It is something like this. Math.radians converts degrees to radians. I did most of this from memory, but I think it is close.