|
Turtles
May 20, 2017 10:11:35 GMT -6
Post by spohnz on May 20, 2017 10:11:35 GMT -6
So when building the course, I want a bunch of turtle programs to introduce. Does anyone have any they want to show? I have one that is a christmas tree, and I can post some that I use already i #ChristMasTree
import turtle
screen = turtle.Screen()
screen.setup(800,600)
circle = turtle.Turtle()
circle.shape('circle')
circle.color('red')
circle.speed('fastest')
circle.up()
square = turtle.Turtle()
square.shape('square')
square.color('green')
square.speed('fastest')
square.up()
circle.goto(0,280)
circle.stamp()
k = 0
for i in range(1, 17):
y = 30*i
for j in range(i-k):
x = 30*j
square.goto(x,-y+280)
square.stamp()
square.goto(-x,-y+280)
square.stamp()
if i % 4 == 0:
x = 30*(j+1)
circle.color('red')
circle.goto(-x,-y+280)
circle.stamp()
circle.goto(x,-y+280)
circle.stamp()
k += 2
if i % 4 == 3:
x = 30*(j+1)
circle.color('yellow')
circle.goto(-x,-y+280)
circle.stamp()
circle.goto(x,-y+280)
circle.stamp()
square.color('brown')
for i in range(17,20):
y = 30*i
for j in range(3):
x = 30*j
square.goto(x,-y+280)
square.stamp()
square.goto(-x,-y+280)
square.stamp()
turtle.exitonclick()
I have some more I will dig out and add but Turtles are fun to play with
|
|
|
Turtles
May 20, 2017 12:09:29 GMT -6
Post by _GrimmCreeper_ on May 20, 2017 12:09:29 GMT -6
I've never used turtles what are they?
|
|
|
Turtles
May 21, 2017 8:55:43 GMT -6
Post by spohnz on May 21, 2017 8:55:43 GMT -6
The turtle mod is a drawing module. Like an 'etch a sketch' This will do a spiral at 92 degrees a turn for a 100 iterations. looping through the color selection I have.
import turtle t = turtle.Pen() turtle.bgcolor("black") colors = ["red", "yellow", "blue", "green"]#jump through list with each iteration for x in range(100): t.pencolor(colors[x%4])#the % is asking for the remainder of x divid by 4 or jumping to the next color int he list. t.forward(x*4) t.left(92)
|
|
|
Turtles
May 21, 2017 9:02:43 GMT -6
Post by _GrimmCreeper_ on May 21, 2017 9:02:43 GMT -6
The turtle mod is a drawing module. Like an 'etch a sketch' This will do a spiral at 92 degrees a turn for a 100 iterations. looping through the color selection I have. import turtle t = turtle.Pen() turtle.bgcolor("black") colors = ["red", "yellow", "blue", "green"]#jump through list with each iteration for x in range(100): t.pencolor(colors[x%4])#the % is asking for the remainder of x divid by 4 or jumping to the next color int he list. t.forward(x*4) t.left(92) That sounds really cool! I will play around with it sometime.
|
|
|
Turtles
Jul 4, 2017 19:53:16 GMT -6
Post by liam c. on Jul 4, 2017 19:53:16 GMT -6
does anyone know how to set an image as a background in turtle and where to place the .gif file in python 36 directory some one once showed me how built i left out a setting on settup of python so reinstalled my shell thank you a lot.
|
|
|
Turtles
Jul 4, 2017 20:10:21 GMT -6
Post by liam c. on Jul 4, 2017 20:10:21 GMT -6
never mind tip make sure image and script are in the same file!!!!!
|
|
|
Turtles
Jul 4, 2017 20:18:38 GMT -6
Post by spohnz on Jul 4, 2017 20:18:38 GMT -6
<span style="font-family: Verdana, Arial; font-size: 10pt;">I tested it and got it to work with turtle.bgpic('directory to image')
import turtle
t=turtle.Pen()
turtle.bgpic('C:\\Users\\Dallas\\10.26.16.PNG')
colors=['red','yellow','blue']
for x in range(100):
t.pencolor(colors[x%3])
t.forward(200)
t.right(91) </span>
|
|
|
Turtles
Jul 4, 2017 20:22:29 GMT -6
Post by spohnz on Jul 4, 2017 20:22:29 GMT -6
|
|
thepifanatic
New Member
pi is awsome people have calculated it past 1 million digits
Posts: 41
|
Post by thepifanatic on Jul 5, 2017 7:30:42 GMT -6
#Mr. Dallas hi its liam i found a tutorial to change the appearance of turtle p1=turtle.Turtle() turtle.register_shape("C:\Users\Liam Crowley\Desktop\all files\all scripts\projects\games\pymonop") p1.shape("C:\Users\Liam Crowley\Desktop\all files\all scripts\projects\games\pymonop\emoji.gif") #but whenever i run it i get a unicode error #(unicode error )'unicodeescape' codec can't #decode bytes iin position 2-#3:truncated\UXXXXXXXX escape #the path was a direct copy from my file #explorer
|
|
thepifanatic
New Member
pi is awsome people have calculated it past 1 million digits
Posts: 41
|
Post by thepifanatic on Jul 5, 2017 7:33:07 GMT -6
oh just saw python 3 errors thread sorry
|
|
|
Turtles
Jul 5, 2017 10:13:13 GMT -6
Post by spohnz on Jul 5, 2017 10:13:13 GMT -6
Hi Liam, Did you figure it out? You were using 3 with a 2 script?
|
|
thepifanatic
New Member
pi is awsome people have calculated it past 1 million digits
Posts: 41
|
Turtles
Jul 5, 2017 19:40:09 GMT -6
Post by thepifanatic on Jul 5, 2017 19:40:09 GMT -6
ohhhhhhhhhhh. that makes sense i just found it online.
|
|
|
Turtles
Jul 5, 2017 19:47:18 GMT -6
Post by spohnz on Jul 5, 2017 19:47:18 GMT -6
Great! glad we could help.
|
|
|
Turtles
Jul 17, 2019 16:19:29 GMT -6
Post by ojeqekipuz on Jul 17, 2019 16:19:29 GMT -6
|
|
|
Turtles
Jul 17, 2019 18:13:43 GMT -6
Post by amilivodo on Jul 17, 2019 18:13:43 GMT -6
|
|