Esempio n. 1
0
from turtle import Turtle, Screen
import random

tim = Turtle()
Turtle.colormode(255)
print(tim)
tim.shape("turtle")


def rand_color():
    r = random.randint(0, 255)
    g = random.randint(0, 255)
    b = random.randint(0, 255)
    ra = (r, g, b)
    return ra


turn = [0, 90, 180, 270]
tim.pensize(15)
tim.speed("fast")


def walk():
    tim.forward(30)
    tim.setheading(random.choice(turn))
    tim.color(rand_color())


for i in range(1, 900):
    walk()
choices = [
    Status.BACKWARD.value,
    Status.FORWARD.value,
    Status.RIGHT.value,
    Status.LEFT.value,
]

# for _ in range(100):
#     handle_status_change(random.choice(choices))

colors = ["red", "blue", "yellow", "green"]
directions = [0, 90, 180, 270]
turtle.pensize(15)
turtle.speed("fastest")
turtle.colormode = 255


def random_color():
    r = random.randint(0, 255)
    g = random.randint(0, 255)
    b = random.randint(0, 255)
    random_color = (r, g, b)
    return random_color


for _ in range(100):
    turtle.color(random_color())
    turtle.forward(30)
    turtle.setheading(random.choice(directions))