class Player: def __init__(self): self.player = Turtle() self.player.color("black") self.player.shape("turtle") self.player._rotate(90) self.player.penup() self.player.goto(STARTING_POSITION) def move(self): self.player.forward(MOVE_DISTANCE)
def random_walk(): t = Turtle() s = Screen() t.pensize(10) t.speed(10) x = [0, 90, 180, 270] for _ in range(200): t.forward(20) t._rotate(random.choice(x)) t.pencolor(random.random(), random.random(), random.random()) s.exitonclick()
def Spriograph(): r = 5 t=Turtle() s= Screen() t.speed(11) for _ in range(int(360/r)): t.circle(100) t._rotate(r) t.pencolor(random.random(),random.random(),random.random()) t.circle(100) r +=1 s.exitonclick()
color_list = [(219, 156, 91), (127, 166, 192), (55, 102, 146), (182, 65, 29), (238, 209, 96), (128, 178, 146), (229, 66, 99), (62, 118, 83), (240, 65, 36), (213, 126, 151), (10, 43, 66), (182, 19, 9), (143, 71, 98), (173, 147, 53), (80, 158, 111), (65, 40, 20), (165, 22, 35), (239, 157, 173), (158, 212, 199), (28, 87, 55), (17, 60, 129), (244, 166, 152), (20, 53, 37), (107, 120, 168), (173, 188, 217), (70, 42, 50)] turtle = Turtle() screen = Screen() screen.colormode(255) turtle.speed(10) turtle.penup() turtle.hideturtle() turtle.setpos(-230, -200) turn = 90 for i in range(10): for j in range(9): turtle.dot(20, random.choice(color_list)) turtle.forward(50) turtle.dot(20, random.choice(color_list)) turtle._rotate(turn) turtle.forward(50) turtle._rotate(turn) turn -= 180 screen.exitonclick()
from turtle import Turtle, Screen import random colours = [ "CornflowerBlue", "DarkOrchid", "IndianRed", "DeepSkyBlue", "LightSeaGreen", "wheat", "SlateGray", "SeaGreen" ] direction = [0, 90, 180, 270] timmy = Turtle() timmy.speed("fastest") for i in range(int(360 / 10)): timmy.circle(100) timmy._rotate(10) screen = Screen() screen.exitonclick()
from turtle import Turtle N = 5 turtles = [] for i in range(N): turtle = Turtle() turtle._rotate(i/N*360) turtles.append(turtle) for _ in range(50): for turtle in turtles: turtle.forward(10)