Created
October 3, 2018 17:47
-
-
Save PaulPolaschek/6d0efc98c4180e0ab1d39e45cda385d5 to your computer and use it in GitHub Desktop.
random python 3 turtle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turtle | |
import random | |
rosi = turtle.Turtle() | |
rosi.speed(0) | |
rosi.shape("turtle") | |
rosi.pensize(2) | |
rosi.pencolor("green") | |
rosi.fillcolor("red") | |
rosi.goto(-100,-50) | |
rosi.k = 0.12 | |
susi = turtle.Turtle() | |
susi.speed(0) | |
susi.shape("turtle") | |
susi.pensize(2) | |
susi.pencolor("red") | |
susi.fillcolor("blue") | |
susi.goto(100,-20) | |
susi.k = 0.245 | |
franzi = turtle.Turtle() | |
franzi.speed(0) | |
franzi.shape("turtle") | |
franzi.pensize(2) | |
franzi.pencolor("black") | |
franzi.fillcolor("purple") | |
franzi.goto(0,20) | |
franzi.k = 0.053 | |
rosi.clear() | |
susi.clear() | |
franzi.clear() | |
rosi.setheading(0) | |
susi.setheading(120) | |
franzi.setheading(240) | |
for x in range(100): | |
for t in (rosi, susi, franzi): | |
t.fd(random.randint(-20,90)) | |
t.left(random.randint(-30,30)) | |
if random.random() < t.k: | |
radius = random.randint(20, 120) | |
winkel = random.randint(0, 360) | |
vorzeichen = random.choice((1,-1)) | |
t.circle(radius, winkel * vorzeichen) | |
if t == rosi and t.distance((0,0)) > 500: | |
#t.penup() | |
#t.home() | |
#t.pendown() | |
t.setheading(t.towards(0,0)) | |
t.fd(random.randint(100,600)) | |
if t == susi and t.distance(rosi) > 500: | |
t.setheading(t.towards(rosi)) | |
t.fd(random.randint(400,600)) | |
if t == franzi and t.distance(susi) > 500: | |
t.setheading(t.towards(susi)) | |
t.fd(random.randint(400,600)) | |
turtle.exitonclick() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment