Format
There really is no hope of making this code even half-way decent without spending the time to rewrite them all properly. Don't want to do any of that
This commit is contained in:
@@ -9,7 +9,9 @@ sideby = int(turtle.numinput("Huhn", "Punkt B, cord y", -100))
|
||||
sidebx = int(turtle.numinput("Huhn", "Punkt B, cord x", -200))
|
||||
sidecy = int(turtle.numinput("Huhn", "Punkt C, cord y", 200))
|
||||
sidecx = int(turtle.numinput("Huhn", "Punkt C, cord x", 0))
|
||||
anzahl_durchgaenge = int(turtle.numinput("Huhn", "Anzahl Durchgänge", 10, minval=1, maxval=100))
|
||||
anzahl_durchgaenge = int(
|
||||
turtle.numinput("Huhn", "Anzahl Durchgänge", 10, minval=1, maxval=100)
|
||||
)
|
||||
stiftdicke = int(turtle.numinput("Huhn", "Stiftdicke", 2, minval=1, maxval=50))
|
||||
durchgang = 0
|
||||
|
||||
@@ -23,8 +25,8 @@ huhn.pu()
|
||||
huhn.ht()
|
||||
|
||||
|
||||
def motion(sideay,sideax,sideby,sidebx,sidecy,sidecx,stiftdicke):
|
||||
edge = random.randint(1,3)
|
||||
def motion(sideay, sideax, sideby, sidebx, sidecy, sidecx, stiftdicke):
|
||||
edge = random.randint(1, 3)
|
||||
if edge == 1:
|
||||
x = sideax
|
||||
y = sideay
|
||||
@@ -35,16 +37,17 @@ def motion(sideay,sideax,sideby,sidebx,sidecy,sidecx,stiftdicke):
|
||||
else:
|
||||
x = sidecx
|
||||
y = sidecy
|
||||
|
||||
|
||||
huhn.setheading(huhn.towards(x, y))
|
||||
nextpos = (math.sqrt((x - huhn.xcor())**2 + (y - huhn.ycor()) **2)) / 2
|
||||
nextpos = (math.sqrt((x - huhn.xcor()) ** 2 + (y - huhn.ycor()) ** 2)) / 2
|
||||
huhn.fd(nextpos)
|
||||
huhn.pd()
|
||||
huhn.dot(stiftdicke)
|
||||
huhn.pu()
|
||||
|
||||
def motion_pre(sideay,sideax,sideby,sidebx,sidecy,sidecx,stiftdicke):
|
||||
edge = random.randint(1,3)
|
||||
|
||||
|
||||
def motion_pre(sideay, sideax, sideby, sidebx, sidecy, sidecx, stiftdicke):
|
||||
edge = random.randint(1, 3)
|
||||
if edge == 1:
|
||||
x = sideax
|
||||
y = sideay
|
||||
@@ -55,33 +58,34 @@ def motion_pre(sideay,sideax,sideby,sidebx,sidecy,sidecx,stiftdicke):
|
||||
else:
|
||||
x = sidecx
|
||||
y = sidecy
|
||||
|
||||
|
||||
huhn.setheading(huhn.towards(x, y))
|
||||
nextpos = (math.sqrt((x - huhn.xcor())**2 + (y - huhn.ycor()) **2)) / 2
|
||||
nextpos = (math.sqrt((x - huhn.xcor()) ** 2 + (y - huhn.ycor()) ** 2)) / 2
|
||||
huhn.fd(nextpos)
|
||||
|
||||
def cagedraw(sideax,sideay,sidebx,sideby,sidecx,sidecy):
|
||||
|
||||
def cagedraw(sideax, sideay, sidebx, sideby, sidecx, sidecy):
|
||||
cage.pu()
|
||||
cage.setpos(sideax,sideay)
|
||||
cage.setpos(sideax, sideay)
|
||||
cage.pd()
|
||||
cage.setpos(sidebx,sideby)
|
||||
cage.setpos(sidecx,sidecy)
|
||||
cage.setpos(sideax,sideay)
|
||||
|
||||
cage.setpos(sidebx, sideby)
|
||||
cage.setpos(sidecx, sidecy)
|
||||
cage.setpos(sideax, sideay)
|
||||
|
||||
|
||||
print("Started drawing Triangle")
|
||||
cagedraw(sideax,sideay,sidebx,sideby,sidecx,sidecy)
|
||||
cagedraw(sideax, sideay, sidebx, sideby, sidecx, sidecy)
|
||||
|
||||
print("Started mapping... Printing Points of Tranche:")
|
||||
turtle.tracer(1000)
|
||||
print("initialisation")
|
||||
for i in range(50):
|
||||
motion_pre(sideay,sideax,sideby,sidebx,sidecy,sidecx,stiftdicke)
|
||||
|
||||
motion_pre(sideay, sideax, sideby, sidebx, sidecy, sidecx, stiftdicke)
|
||||
|
||||
for i in range(anzahl_durchgaenge):
|
||||
for i in range(1000):
|
||||
motion(sideay,sideax,sideby,sidebx,sidecy,sidecx,stiftdicke)
|
||||
motion(sideay, sideax, sideby, sidebx, sidecy, sidecx, stiftdicke)
|
||||
durchgang += 1
|
||||
print(durchgang,"/", anzahl_durchgaenge)
|
||||
print(durchgang, "/", anzahl_durchgaenge)
|
||||
print("done, click to exit")
|
||||
turtle.exitonclick()
|
||||
turtle.exitonclick()
|
||||
|
||||
Reference in New Issue
Block a user