Simple Turtle Race Game with Python

 Create main.py file and paste the following code


import turtle as t
screen = t.Screen()
screen.setup(height=500, width=600)
uer_bet = screen.textinput(prompt="Guess, which turtle would win the race?", title="Input color name")
colors = ["red", "brown", "cyan", "green", "orange", "pink"]
y_position = [0, -30, 30, -60, 60, 90]
import random

all_turtles = []
run = True

for turtle in range(0, 6):
turtles = t.Turtle(shape="turtle")
turtles.penup()
turtles.goto(x=-250, y=y_position[turtle])
turtles.color(colors[turtle])
all_turtles.append(turtles)

turtle_speed = [10, 15, 20, 25, 30, 5]

def random_walk(turtles):
global run
for turtle in turtles:
turtle.forward(random.choice(turtle_speed))
if turtle.xcor() > 250:
run = False


while run:
random_walk(all_turtles)


screen.exitonclick()








# Thats it, you can run and enjoy now.

Comments

Popular posts from this blog

Where Does Intelligence Begin?

Random is not actually indeterministic, its hard to calculate.

Existence Game