I would like to use python's turtles to effectively simulate a lego robot. The lego robots have the ability to sample the colour that the robot is positioned over. With this in mind, I would like to create a background maze and have the robot find its way though the maze. I hope to use this with grade 10 programming students.
So far, I can create a simple canvas using tkinter and with a coloured rectangle on that canvas. I can place the turtle on the canvas and have them co-exist. The turtle can be placed on the coloured rectangle.
Now I just need to be able to have the colour sampled in some way. This may be done through getting the turtle's position and then sampling that coordinate. But I am stuck at this point.
Here's my code so far:
from tkinter import Tk, Canvas, Frame, BOTH
import turtle
top = Tk()
C = Canvas(top, height=500, width=600)
Doug = turtle.RawTurtle(C)
rectangle = C.create_rectangle(30, 10, 120, 80, outline="#fb0", fill="#fb0")
Doug.fd(50)
Doug.rt(90)
Doug.fd(50)
C.pack(fill=BOTH, expand=1)
top.mainloop()
I do notice that when I run the code, the turtle's 'trail' is behind the rectangle, suggesting a layering problem.