From bedcd0a5f9b09638227f967eddc51dbe9e4eea2a Mon Sep 17 00:00:00 2001 From: pythonboi Date: Sun, 10 Apr 2022 01:06:21 -0400 Subject: [PATCH] fix the issue with the turtle racing --- turtleRace.py | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/turtleRace.py b/turtleRace.py index e02f2a1..67f9a57 100644 --- a/turtleRace.py +++ b/turtleRace.py @@ -10,20 +10,21 @@ # Create a scree size to use for the window screen.setup(700, 500) +is_RaceOn = False + # Ask a question and Enter you input message -# Answer = screen.textinput("Question", prompt="Which turtle color will win the race?") -# +Answer = screen.textinput("Question", prompt="Which turtle color will win the race?") + # print(Answer) -rainbowColors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo']#, 'violet'] +rainbowColors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'] -userNames = ['jenny', 'pam', 'tom', 'jane', 'jim', 'kim']#, #'sam'] +# userNames = ['jenny', 'pam', 'tom', 'jane', 'jim', 'kim']#, #'sam'] -y_Position = [30, 60, 90, 0, -30, -60, -90] +y_Position = [-30, -60, -90, 0, 30, 60, 90] -colorTaken = [] -nameTaken = [] +newTurtle = [] # # def changeRange(x, y): @@ -32,16 +33,32 @@ # num = num + 10 # turtle.goto(-335, num) -for pick in range(0, 6): + +for pick in range(0, 7): userNames = Turtle() # userNames.shape('turtle') userNames.shape("turtle") - #userNames.color(pick) + userNames.color(rainbowColors[pick]) userNames.penup() - userNames.goto(-335, y_Position[pick]) - userNames.color() - # userNames.goto(changeRange(x, y=num)) + newTurtle.append(userNames) + +print(newTurtle) + + +if Answer: + is_RaceOn = True + + +while is_RaceOn: + + for turtle in newTurtle: + print(turtle) + count = random.randint(0, 10) + #newSelect = random.choice(y_Position) + turtle.forward(count) + + # def pickUser():