When you start up the game, you can see 5 turtle racing for the finish line.
In order to play the game, you must copy the code below and paste it into your python file. After that, run the code and enjoy!
Cop the code for FREE!:
import turtle
import random
screen = turtle.Screen()
screen.title("Turtle Race")
screen.bgcolor("white")
track = turtle.Turtle()
track.speed(0)
track.color("black")
track.width(5)
track.penup()
track.goto(-200, 140)
track.pendown()
for _ in range(16):
track.right(90)
track.forward(280)
colors = ["red", "green", "blue", "orange", "purple"]
turtles = []
for i, color in enumerate(colors):
turtle_obj = turtle.Turtle()
turtle_obj.shape("turtle")
turtle_obj.color(color)
turtle_obj.penup()
turtle_obj.goto(-220, 100 - i * 40)
turtles.append(turtle_obj)
while True:
for turtle_obj in turtles:
distance = random.randint(1, 5)
turtle_obj.forward(distance)
if turtle_obj.xcor() >= 200:
winner = turtle_obj.color()[0]
turtle_obj.write("Winner!", align="center", font=("Arial", 16, "bold"))
break
if turtle_obj.xcor() >= 200:
break
text = turtle.Turtle()
text.penup()
text.goto(0, -200)
text.color("black")
text.write("The " + winner + " turtle wins!", align="center", font=("Arial", 20, "bold"))
turtle.exitonclick()