So as of now, I have this code;
import turtle
import random
def getColor():
selection = random.randint(1,3)
if selection == 1:
return "green"
elif selection == 2:
return "red"
else:
return "blue"
def drawPerson(my_turtle, x, y):
my_turtle.penup()
my_turtle.goto(x,y)
my_turtle.pendown()
my_turtle.pensize(3)
xul.color = getColor()
print(xul.color)
if xul.color == "green":
xul.color("green")
elif xul.color == "red":
xul.color("red")
else:
xul.color("blue")
xul.forward(90)
xul.left(90)
xul.forward(90)
xul.left(90)
xul.forward(90)
xul.left(90)
xul.forward(90)
xul.left(90)
xul = turtle.Turtle()
drawPerson(xul,150,150)
drawPerson(xul,-150,150)
drawPerson(xul,-150,-150)
drawPerson(xul,150,-150)
drawPerson(xul,0,0)
The problem is.. I can generate the color, it prints the color it draws all the shapes, but I cannot figure out how to make the color actually get applied to the turtle before it draws. I have tried things like;
xul.color("getColor")
and numerous other things, but I cannot seem to figure it out.. If someone could just give me the line of code that I am missing I'd greatly GREATLY appreciate it! Thanks!
Aucun commentaire:
Enregistrer un commentaire