From 91f62095602c9234436d0ae6f9ff4d471953fd08 Mon Sep 17 00:00:00 2001 From: pythonboi Date: Sun, 10 Apr 2022 16:25:47 -0400 Subject: [PATCH] add two player team game --- turtleRace.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/turtleRace.py b/turtleRace.py index 67f9a57..5ceb51f 100644 --- a/turtleRace.py +++ b/turtleRace.py @@ -1,4 +1,4 @@ -import turtle +# importing the turtle from turtle import Turtle, Screen import random @@ -14,7 +14,8 @@ # Ask a question and Enter you input message -Answer = screen.textinput("Question", prompt="Which turtle color will win the race?") +player1 = screen.textinput("Player1 Choose", prompt="Which turtle color will win the race?") +player2 = screen.textinput("Player2 Choose", prompt="Which turtle color will win the race?") # print(Answer) @@ -35,7 +36,6 @@ for pick in range(0, 7): - userNames = Turtle() # userNames.shape('turtle') userNames.shape("turtle") userNames.color(rainbowColors[pick]) @@ -43,33 +43,40 @@ userNames.goto(-335, y_Position[pick]) newTurtle.append(userNames) -print(newTurtle) - +# print(newTurtle) -if Answer: +if player1 != '' and player2 != '': is_RaceOn = True - while is_RaceOn: for turtle in newTurtle: - print(turtle) + if turtle.xcor() > 320: + winnerTurtle = turtle.pencolor() + + print(winnerTurtle) + is_RaceOn = False + if player1 == winnerTurtle: + print(f"Player1 Won, the {winnerTurtle} turtle won the race") + + elif player2 == winnerTurtle: + print(f"Player2 Won, the {winnerTurtle} turtle won the race") + else: + print(f"You both loose, the {winnerTurtle} turtle won the race") + # print(turtle) count = random.randint(0, 10) - #newSelect = random.choice(y_Position) turtle.forward(count) - # def pickUser(): # for name in userNames: # name. - - # for n in userNames: - # if n in userNames: - # n.goto(-335, 30) +# for n in userNames: +# if n in userNames: +# n.goto(-335, 30) # pam = Turtle() # pam.color("orange")