حلي لمشروع لعبة سباق السلاحف , ما رأيكم؟

import random
from turtle import Turtle, Screen

window = Screen()
window.setup(1.0,1.0)
window.title("SAM Turtles Race")

game_on = True
colors = ("red", "green", "blue")  



while game_on:

    user_choice = window.textinput("Make your bet", "Guess the winner:\nType a color: Red, Blue or Green?").lower()
    if user_choice in colors:


        sam = Turtle()
        tom = Turtle()
        jane = Turtle()
        writer = Turtle()

        writer.hideturtle()

        sam.color("red")
        tom.color("blue")
        jane.color("green")
        writer.color('white')

        sam.shape('turtle')
        tom.shape("turtle")
        jane.shape('turtle')

        sam.penup()
        tom.penup()
        jane.penup()
        writer.penup()


        sam.turtlesize(1.5)
        tom.turtlesize(1.5)
        jane.turtlesize(1.5)

        sam.speed('normal')
        tom.speed('normal')
        jane.speed('normal')

        sam.goto(-650, 230)
        tom.goto(-650,0)
        jane.goto(-650, -230)

            
        turtles = (sam, tom, jane)  
            

        game_on = False
        while sam.xcor() < 660 and tom.xcor() < 660 and jane.xcor() < 660:
            random_turtle = random.choice(turtles)
            random_turtle.forward(4)
        if sam.xcor() >= 660 and user_choice == 'red' or tom.xcor() >= 660 and user_choice == 'blue' or jane.xcor() >= 660 and user_choice == 'green':
            result = 'You win!'
        else: 
            result = 'you lose!'
        window.bgcolor("pink")
        writer.goto(0,0)
        writer.write(result, align='center', font= ("Arial",60,'normal'))
    

window.exitonclick()

3 إعجابات

جميل جداً ما شاء الله :heart::tulip: