Example #1
1
def banner(s):
    """
    Display a message then quit.
    :param s: String of your message
    """
    turtle.home()
    turtle.color('black')
    turtle.write(s, True, align='center', font=('Arial', 48, 'italic'))
    time.sleep(2)
    turtle.undo()
    lander.delete()
def grid():
    """this function draws the grid lines for the tic-tac-toe board"""
    up()
    right(90)
    forward(65)  # moves the turtle down to start the grid
    left(90)
    forward(30)  # moves the turtle over to position for the vertical lines
    down()
    left(90)
    forward(180) # draws the first grid
    up()
    left(90)
    forward(60)  # moves for the second vertical line
    down()
    left(90)
    forward(180) # draws the second line
    left(90)
    up()
    forward(120) # moves over the the bottom right of the imaginary square around
                 # the tic-tac-toe board
    left(90)
    forward(60)  # moves the turtle to the position for the horizontal lines
    left(90)
    down()
    forward(180) # draws the first horizontal
    up()
    right(90)
    forward(60)  # moves up for the second horizontal
    down()
    right(90)
    forward(180) # draws the second horizontal
    up()
    turtle.home()
Example #3
0
def plano2d():
  turtle.penup()

  for i in range(13):
    y = 264 - (44 *i)
    turtle.penup()
    turtle.setposition(-264,y)
    turtle.pendown()
    turtle.forward(528)
  
  turtle.right(90)

  for i in range(13):
    x = -264 + (44*i)
    turtle.penup()
    turtle.setposition(x,264)
    turtle.pendown()
    turtle.forward(528)
  
  turtle.penup()
  turtle.home()
  turtle.pendown()
  turtle.color("blue")         
  turtle.pensize(3)

  for i in range(4):
    grados = 90 * (i+1)
    turtle.home()
    turtle.left(grados)
    turtle.forward(264) 
Example #4
0
def theStem(stemLength=100):
	turtle.home()
	turtle.forward(25)
	turtle.left(90)
	turtle.pensize(4)
	turtle.color("green")
	turtle.forward(stemLength)
Example #5
0
def message(m1, m2):             # 메시지를 화면에 표시하는 함수
    t.clear()
    t.goto(0, 100)
    t.write(m1, False, "center", ("", 20))
    t.goto(0, -100)
    t.write(m2, False, "center", ("", 15))
    t.home()
Example #6
0
def Plus():
	turtle.forward(100)
	turtle.right(90)
	turtle.forward(100)
	turtle.right(-90)
	turtle.forward(100)
	turtle.right(-90)
	turtle.forward(100)
	turtle.right(90)
	turtle.forward(100)
	turtle.right(-90)
	turtle.forward(100)
	turtle.right(-90)
	turtle.forward(100)
	turtle.right(90)
	turtle.forward(100)
	turtle.right(-90)
	turtle.forward(100)
	turtle.right(-90)
	turtle.forward(100)
	turtle.right(90)
	turtle.forward(100)
	turtle.right(-90)
	turtle.forward(100)
	turtle.home()
Example #7
0
def at(x, y):
    turtle.penup()
    turtle.home()
    turtle.forward(x)
    turtle.left(90)
    turtle.forward(y)
    turtle.pendown()
Example #8
0
def passeio(dim, lado, passos):    
    # Prepara grelha
    turtle.speed(0)
    grelha_2(dim,lado)
    turtle.color('red')
    turtle.home()
    turtle.pendown()
    # Passeio
    turtle.speed(6)
    turtle.dot()
    turtle.showturtle()
    lim_x = lim_y = (dim*lado)//2
    cor_x = 0
    cor_y = 0
    for i in range(passos):
        vai_para = random.choice(['N','E','S','W'])
        if (vai_para == 'N') and (cor_y < lim_y):
            cor_y += lado
            turtle.setheading(90)
            turtle.fd(lado)
        elif (vai_para == 'E') and (cor_x < lim_x):
            cor_x += lado
            turtle.setheading(0)
            turtle.fd(lado)
        elif (vai_para == 'S') and (cor_y > -lim_y):
            cor_y -= lado
            turtle.setheading(270)
            turtle.fd(lado)
        elif (vai_para == 'W') and (cor_x > -lim_x):
            cor_x -= lado
            turtle.setheading(180)
            turtle.fd(lado) 
        else:
            print((vai_para,turtle.xcor(),turtle.ycor()))
            continue
Example #9
0
def hands( freq=166 ):
    """Draw three hands.

    :param freq: Frequency of refresh in milliseconds.
    """
    global running
    now= datetime.datetime.now()
    time= now.time()
    h, m, s, ms = time.hour, time.minute, time.second, int(time.microsecond/1000)

    # Erase old hands.
    while turtle.undobufferentries():
        turtle.undo()

    # Draw new hands.
    hand( h*5+m/60+s/3600, .6*R, 3 )
    hand( m+s/60, .8*R, 2 )
    hand( s+ms/1000, .9*R, 1 )

    # Draw date and time
    turtle.penup(); turtle.home()
    turtle.goto( 0, -120 ); turtle.write( now.strftime("%b %d %H:%M:%S"), align="center", font=("Helvetica", 24, "normal") )

    # Reschedule hands function
    if running:
        # Reset timer for next second (including microsecond tweak)
        turtle.ontimer( hands, freq-(ms%freq) )
Example #10
0
def body():
    turtle.penup()
    turtle.home()
    turtle.left(90)
    turtle.forward(50)
    turtle.pendown()
    turtle.forward(90)
def dragon_curve_tiling():
    for heading in [0, 90, 180, 270]:
        t.penup()
        t.home()
        t.setheading(heading)
        changeColor()
        t.pendown()
        dragon_curve(iteration, size, swap=True)
Example #12
0
def maketree(name, scale, L):
	turtle.home()
	turtle.begin_poly()
	stack = [ (0, 0) ]
	maketree_r(stack, L, scale)
	turtle.end_poly()
	poly = turtle.get_poly()
	turtle.register_shape(name, poly)
Example #13
0
def makepop(fn, *args):
	turtle.home()
	turtle.begin_poly()
	fn(*args)
	turtle.end_poly()
	name = 'pop%d' % len(POPS)
	turtle.register_shape(name, turtle.get_poly())
	POPS.append(name)
Example #14
0
def rightleg():
    turtle.penup()
    turtle.home()
    turtle.left(90)
    turtle.forward(50)
    turtle.right(135)
    turtle.pendown()
    turtle.forward(50)
Example #15
0
def rightarm():
    turtle.penup()
    turtle.home()
    turtle.left(90)
    turtle.forward(120)
    turtle.right(45)
    turtle.pendown()
    turtle.forward(50)
Example #16
0
def reg_bullet():
    turtle.home()
    turtle.setpos(0, -5)
    turtle.begin_poly()
    turtle.circle(5, None, None)
    turtle.end_poly()
    circ = turtle.get_poly()
    turtle.register_shape('bullet', circ)
Example #17
0
def head():
    turtle.penup()
    turtle.home()
    turtle.left(90)
    turtle.forward(140)
    turtle.right(90)
    turtle.pendown()
    turtle.circle(20)
Example #18
0
def drawBoard():            # Turtle function to draw the entire board
        t.penup()
        t.forward(-300)
        t.pendown()
        for i in range(4):        ##This is when a catastrophe happens, biome gets deleted
            biomeDraw("blue")
            biomeDraw("red")
        t.home()
def drawAnswer(x, path) :
    initialize()
    drawB(x[0],x[1])
    for pos in path :
        drawP(pos)
    t.penup()
    t.home()
    sleep(2)
Example #20
0
def makeground():
	for i in range(GROUNDLEN-3, GROUNDLEN+9):
		turtle.home()
		turtle.begin_poly()
		turtle.fd(i)
		turtle.end_poly()
		name = 'gr%d' % i
		turtle.register_shape(name, turtle.get_poly())
		GROUND.append(name)
Example #21
0
def drawcircle1():
# this function draws the inner circle.
    turtle.right(90)
    turtle.forward(30)
    turtle.left(90)
    turtle.down()
    turtle.circle(30)
    turtle.up()
    turtle.home()
Example #22
0
def reg_sun():
    global sundiam
    turtle.home()
    turtle.setpos(0, -sundiam / 2)
    turtle.begin_poly()
    turtle.circle(sundiam/2, None, None)
    turtle.end_poly()
    circ = turtle.get_poly()
    turtle.register_shape('sun', circ)
Example #23
0
 def __drawstate(self, x, y, state):
     turtle.penup()
     turtle.home()
     turtle.setpos(x*10, y*10)
     if state == 1:
         turtle.pen(fillcolor="black")
     if state == 0:
         turtle.pen(fillcolor="white")
     turtle.pendown()
     self.__drawsquare()
Example #24
0
def main():
# this is the function that actually draws the traingles.
    drawtriangle()
    nexttriangle1()
    drawtriangle()
    nexttriangle2()
    drawtriangle()
    nexttriangle3()
    drawtriangle()
    turtle.home()
Example #25
0
def drawBoard():            # Turtle function to draw the entire board
    global catastropheNumber
    t.penup()
    t.forward(-300)
    t.pendown()
    for i in range(len(biomeList)):
        if i == pythonShine and godMode == True:
            biomeDraw("green")
        else:
            biomeDraw("tan")
    t.home()
def banner(s):
    """
    Display a message then quit.
    :param s: String of your message
    """
    turtle.home()
    turtle.color("black")
    turtle.write(s, True, align="center", font=("Arial", 48, "italic"))
    time.sleep(2)
    turtle.undo()
    lander.delete()
def drawBoard():
    global catastropheNumber
    t.penup()
    t.forward(-300)
    t.pendown()
    for i in range((8 - catastropheNumber)):
        if i == pythonShine and godMode == True:
            biomeDraw("green")
        else:
            biomeDraw("tan")
    t.home()
Example #28
0
def hand( angle_sec, radius, width ):
    """Draw one hand at the given angle, radius and width.

    :param angle_sec: Angle, measured in seconds 0..60.
    :param radius: Length of hand.
    :param width: Width of stroke.
    """
    turtle.penup(); turtle.home()
    turtle.pendown()
    turtle.setheading( 90-angle_sec*6 )
    turtle.pensize( width )
    turtle.forward( radius )
Example #29
0
def stand():
    turtle.penup()
    turtle.home()
    turtle.left(180)
    turtle.forward(100)
    turtle.right(90)
    turtle.pendown()
    turtle.forward(200)
    turtle.right(90)
    turtle.forward(100)
    turtle.right(90)
    turtle.forward(20)
Example #30
0
def maketweendata(kf1, kf2, steps, scale):
	global _kfsegments
	assert len(kf1) == len(kf2)	# must be able to match segments up

	L = []
	for i in range(len(kf1)):
		[ (x1, y1), (x2, y2) ] = normalize(kf1, i, scale)

		# Euclidean distance gives segment length
		seglen = ( (x2 - x1) ** 2 + (y2 - y1) ** 2 ) ** 0.5

		# make line segment into shape
		turtle.home()
		turtle.begin_poly()
		turtle.fd(seglen)
		turtle.end_poly()
		name = 'kf%d' % _kfsegments
		_kfsegments += 1
		turtle.register_shape(name, turtle.get_poly())

		# and compute initial heading
		heading = getheading(x1, y1, x2, y2)

		# extract out corresponding segment from key frame 2
		[ (x1b, y1b), (x2b, y2b) ] = normalize(kf2, i, scale)

		# use it to compute deltas for x, y, and heading; this is
		# where we need to be after N steps
		dx = x1b - x1
		dy = y1b - y1
		dh = getheading(x1b, y1b, x2b, y2b) - heading
		# weird special case that cropped up between BKF3 and BKF4 of
		# bird flap, where the computed delta in the heading takes the
		# long way around, as it were - adjust it to compensate
		if dh > 180:
			dh = dh - 360
		elif dh < -180:
			dh = dh + 360
		dx /= steps
		dy /= steps
		dh /= steps

		# place everything in a container
		c = Tween()
		c.name = name
		c.x, c.y = x1, y1
		c.heading = heading
		c.dx, c.dy = dx, dy
		c.dh = dh
		L.append(c)

	return L
Example #31
0
def voltar_casa():
    '''Retorna a tartaruga para a posição original (coordenadas 0,0)'''
    turtle.home()
Example #32
0
from turtle import *

shape("turtle")
import turtle
turtle.penup()
for i in range(1, 100, 90):
    turtle.right(90)    # Face South
    turtle.forward(i)   # Move one radius
    turtle.right(270)   # Back to start heading
    turtle.pendown()    # Put the pen back down
    turtle.circle(i)    # Draw a circle
    turtle.penup()      # Pen up while we go home
    turtle.home()       # Head back to the start pos

mainloop()
def draw_O():
    """this function draws an 'o' in the center of the white cell of the board"""
    down()
    circle(25)  # draws the 'O' for the cell
    up()
    turtle.home()
Example #34
0
def ShowTime():
    tim = datetime.today()

    t.pencolor("black")

    t.tracer(False)  # 不显示绘制的过程,直接显示绘制结果
    # 写日期
    t.setx(0)
    t.sety(-50)
    # 定位到(0,-50)
    t.pd()  # 放下笔
    """
    turtle.write(s [,font=("font-name",font_size,"font_type")])
    """
    # t.write("2019 12 06",font=('Arial', 15, 'normal'))
    t.write(Date(tim), align="center", font=("Courier", 15, "bold"))
    t.pu()  # 抬起笔

    # 写时间
    t.setx(0)
    t.sety(-70)
    # 定位到(0,-70)
    t.pd()  # 放下笔
    t.write(str(tim.hour) + ":" + str(tim.minute) + ":" + str(tim.second),
            align="center",
            font=("Courier", 15, "bold"))
    t.pu()  # 抬起笔

    # 写星期
    t.setx(0)
    t.sety(60)
    # 定位到(0,60)
    t.pd()  # 放下笔
    t.write(Week(tim), align="center", font=("Courier", 15, "bold"))
    t.pu()  # 抬起笔

    # 绘指针(时针和分针)
    t.home()  # 回到起始状态
    t.lt(90)  # 起始指向是12,即0点,此时角度是90度

    t.rt(tim.hour * 30 + 30 / 60 * tim.minute)  # 向右转的角度
    # 时针的粗细3 长度80
    t.pensize(3)
    t.pd()  # 落笔
    t.fd(80)

    # 分针
    t.up()  # 起笔

    t.home()  # 回到起始状态
    t.lt(90)  # 起始指向是12,即0点,此时角度是90度

    t.rt(tim.minute * 6)  # 向右转的角度
    # 分针的粗细2 长度110
    t.pensize(2)
    t.pd()  # 落笔
    t.fd(110)

    # 秒针
    t.up()  # 起笔

    t.pencolor("red")

    t.home()  # 回到起始状态
    t.lt(90)  # 起始指向是12,即0点,此时角度是90度

    t.rt(tim.second * 6)  # 向右转的角度
    # 分针的粗细1 长度140
    t.pensize(1)
    t.pd()  # 落笔
    t.fd(140)

    t.pu()  # 抬起笔

    t.tracer(True)

    # t.reset()  # 清空画板 ,不能用,一用就将整个画布都清空了,什么都没有了

    # # 1000ms后继续调用tick ,即1秒
    t.ontimer(ShowTime, 100)  # 0.1秒
Example #35
0
"""
Created on Sat Jul  4 08:01:32 2020

@author: DelowaR
"""
import turtle as tl

running = True
tl.title('turtle GO')
screen = tl.getscreen()
tl.bgcolor(1, 1, 0)
# draw box using position
tl.goto(100, 0)
tl.goto(100, 50)
tl.goto(0, 50)
tl.home()  # move cursor into 0,0 position
# tl.backward(100)

tl.penup()
tl.goto(-100, -100)
tl.down()

# change the pen size
tl.pensize(10)

tl.circle(100)

# resize the turtle shape!
tl.shapesize(5, 5, 5)
tl.fillcolor('red')
tl.color('white', 'black')
Example #36
0
def home(x, y):
    t.home()
    t.left(90)
Example #37
0
penup()  # presun pro druhou horu
right(180)
forward((trojuhelnik_strana / 5) * 4)
left(120)
forward(180)
pendown()
fillcolor('#79797F')  # druha, mensi hora
pencolor('#79797F')
begin_fill()
for _ in range(3):
    forward(450)
    left(120)
end_fill()

###################### pulkruh ######################
home()
n = 100
vnitrni_uhel = 180 * (1 - 2 / n)
vnejsi_uhel = 180 - vnitrni_uhel
delka_strany = 30
fillcolor('#21170D')
pencolor('#21170D')
begin_fill()
for _ in range(n):
    forward(delka_strany)
    right(vnejsi_uhel)
end_fill()

####################################  domecky ################################
setposition(0, 0)
sire_domu = 50
Example #38
0
tu.lt(135)
tu.fd(15)

# second wheel
tu.bk(15)
tu.lt(45)
tu.fd(20)
tu.color('orange')
tu.lt(75)
tu.fd(50)
tu.lt(30)
hexagon(20, 'yellow')

# tree
tu.penup()
tu.home()
tu.setx(100)
tu.pendown()
tu.lt(90)
tu.color('brown')
tu.fd(50)
tree_branch()
tu.fd(70)
tree_branch()
tu.fd(50)
tu.color('green')
tu.fd(60)
hexagon(60, 'green')

tu.hideturtle()
tu.done()
Example #39
0
    turtle.forward(50)    # moves the turtle to start a new triangle
    turtle.down()         # puts the turtle down for drawing a line
    turtle.right(270)     #turns the turtle to draw a side of the triangle
    turtle.forward(40)    # makes first side
    turtle.right(115)
    turtle.forward(50)    # makes second side
    turtle.right(132)
    turtle.forward(50)    # makes third side
    
    turtle.up() 
    

triangle()                # draws the right triangle


turtle.home()             # returns turtle to starting/default position for left triangle

left(90)
forward(40) # these movements reposition turtle for next triangle
up()
left(90)


triangle()                # draws the left triangle

turtle.home()



forward(20)
left(90)
Example #40
0
t.up()  # 펜 올린다.

#이쪽 벽면은 속도 느려짐

t.goto(-255, 250)  # -255,250으로 이동(이쪽 벽면은 속도 느려짐)
t.fillcolor("yellow")  # 도형 채우기 노란색으로 설정
t.begin_fill()  # 도형 색채울 준비
t.down()  # 펜 내린다.
t.goto(-255, -250)  # -255,-250으로 이동
t.goto(-265, -250)  # -265,-250으로 이동
t.goto(-265, 250)  # -265,250으로 이동
t.goto(-255, 250)  # -255,250으로 이동
t.end_fill()  # 도형 색 채우기

t.up()  # 펜 올린다.
t.home()  # 사각형 가운데로 이동
t.down()  # 펜 내린다.

angle = random.randint(1, 360)  # 랜덤으로 각도 1~360사이로 설정

t.setheading(angle)  # 거북이 방향 무작위로 변경

for x in range(100):
    while -250 <= t.xcor() <= 250 and -250 <= t.ycor(
    ) <= 250:  # x와 y의 각도가 사각형에 맞닿으면 멈추도록 설정

        t.forward(1)  # 거북이 앞으로 1만큼 감
        a = t.heading()  # a에 현재 각도 저장

        if t.xcor() >= 250:  # 만약 오른쪽 벽면에 부딪쳤을 때
            if 270 <= a <= 360:  # 만약 오른쪽 벽면에 부딪쳤는데 각도가 270 ~ 360사이 일때
Example #41
0
def home():
    turtle.penup()
    turtle.home()
    turtle.pendown()
Example #42
0
import turtle as tt

# draw a window for the game
screen = tt.Screen()
screen.title('Спираль')
screen.bgcolor('blue')
screen.setup (width=200, height=200)

step=0.2
while(True):
    tt.left(2)
    tt.forward(step)
    step+=0.01
    #TODO: добавить проверку на отход на расстояние 100 от (0,0) и возврат черепахи home()
    if tt.distance(0,0) > 100:
        tt.penup()
        tt.home()
        tt.pendown()
        step=0.1
import turtle as t  # tutle이라는 모듈을 t라는 이름으로 import하라
# tutle.shape() 대신에 t.shape() 으로 사용가능

t.shape('turtle')

t.circle(50)  #원그리기 (반지름길이)
t.color('red')
t.pensize(3)  #선 굵기

for i in range(4):
    t.forward(100)
    t.left(90)

t.forward(100)
#t.hideturtle() # turtle 숨김
t.home()  # tutle 초기 위치로 옮김
t.clear()  # 화면을 초기 상태로

t.done()
'''
myTurtle = turtle.Turtle() # 객체선언
myTurtle.fillcolor('red') # 색
myTurtle.shape('turtle') # 객체 타입
myTurtle.shapesize(3,3,1) # 세로w, 가로 h, 윤곽선 b배
myTurtle.forward(100) # 앞으로 100픽셀
myTurtle.left(120) # left 각도 변경
myTurtle.forward(100) 
myTurtle.left(120)
myTurtle.forward(100) 
myTurtle.left(120)
#myTurtle.backward(50) # 뒤로 50 픽셀
Example #44
0
def banner(s):
    turtle.home()
    turtle.color('black')
    turtle.write(s, True, align='center', font=('Arial', 48, 'italic'))
    time.sleep(3)
    turtle.undo()
Example #45
0
    turtle.forward(75)
    turtle.right(144)
turtle.penup()

# makes green spiral
turtle.goto(200, -250)
turtle.pencolor("chartreuse2")
turtle.pendown()
for i in range(39):
    turtle.forward(200)
    turtle.left(123)
turtle.penup()

# make green star
turtle.goto(305, -245)
turtle.pendown()
for i in range(5):
    turtle.forward(75)
    turtle.right(144)
turtle.penup()

# makes words in the center
turtle.home()
turtle.pencolor("black")
turtle.pendown()
turtle.write("hello ;)",
             move=False,
             align="center",
             font=("Comic Sans MS", 100, "normal"))
turtle.penup()
Example #46
0
import turtle

my_turtle = turtle.Turtle()

x = 25
l = 100

my_turtle = turtle.home()


def draw_circle(x: int, y: int, radius: int, color: str):
    turtle.pu()

    turtle.setx(x)
    turtle.sety(y)
    turtle.pd()
    turtle.begin_fill()
    turtle.fillcolor(color)
    turtle.circle(radius)
    turtle.end_fill()
    turtle.ht()


my_turtle = draw_circle(
    -50,
    50,
    100,
    'blue',
)
my_turtle = draw_circle(50, -50, 100, 'green')
my_turtle = draw_circle(0, 0, 100, 'red')
Example #47
0
 def reset(self):
     super(TurtleGui, self).reset()
     std_turtle.penup()
     std_turtle.home()
     std_turtle.clear()
     std_turtle.pendown()
Example #48
0
def yinyang(diameter, color_1="black", color_2="white"):
    yin(diameter, color_1, color_2)
    home()
    left(180)
    yin(diameter, color_2, color_1)
    hideturtle()
Example #49
0
def draw_triangle(x: float, y: float, hypotenuse: float, angle: float):
    drawingScale = 10
    turtle.forward(x * drawingScale)
    turtle.setheading(90)
    turtle.forward(y * drawingScale)
    turtle.home()
    tl.pendown()
    tl.left(30)
    tl.forward(length)
    create_branches(n - 1)
    tl.penup()
    tl.backward(length)
    tl.right(60)
    tl.pendown()
    tl.forward(length)
    create_branches(n - 1)
    tl.penup()
    tl.backward(length)
    tl.left(30)


tl.up()
tl.home()
tl.sety(-50)
# tl.forward(250)
tl.left(90)
# tl.goto((0, -330))

tl.pendown()
tl.forward(50)
create_branches(count)
signature()
tl.speed(1)
tl.hideturtle()

tl.exitonclick()
Example #51
0
def home():
    turtle.home()
 def do_home(self, arg):
     'Return turtle to the home position:  HOME'
     turtle.home()
Example #53
0
def circle_O(turtle):
    turtle.pendown()
    turtle.circle(30)
    turtle.penup()
    turtle.home()
Example #54
0
 def jerryGoHome(self):
     """ Lift the jerry and Reset position then put jerry back down """
     jerry.up()
     jerry.home()
     jerry.down()
def k6():
        turtle.home()
        move.home()
Example #56
0
import turtle as t
t.shape("turtle")
t.up()
t.fd(250)
t.lt(90)
t.fd(250)
t.lt(90)
t.down()
for x in range(4):
    t.fd(500)
    t.lt(90)

t.up()
t.home()
t.down()
import random
a = random.randint(1, 360)
t.seth(a)
while True:
    x = t.xcor()
    y = t.ycor()
    ang = t.heading()
    if -245 < x < 245 and -245 < y < 245:
        t.fd(10)
    else:
        if x >= 245:
            t.seth(180 - ang)
            t.fd(10)
        if y >= 245:
            t.seth(-ang)
            t.fd(10)
Example #57
0
def drawStemAndTriangle(stemLength, edgeLength):
    turtle.forward(stemLength)
    drawTriangle(edgeLength)
    turtle.home()
t.shape("circle")  #모양은 동그라미 공으로
t.up()  #펜 꼬리들고
t.goto(-250, -250)  #x=-250 y=-250 좌표로 이동
t.down()  #펜 꼬리 내리구
t.speed(0)  #제일빠르게


def ground(n):  #함수를 만들었어요
    for x in range(n):  #이 함수는 500x500 그라운드를 위한 거에요
        t.fd(500)  #앞으로 500만큼
        t.lt(90)  #왼쪽으로 90돌구


ground(4)  #그렇게 n=4 를 입력하면 그라운드를 만듭니다.
t.up()  #펜 꼬리 들고
t.home()  #원래 위치로

a = random.randint(0, 360)  #0~360의 값을 랜덤으로 정해요
t.setheading(a)  #a도로 거북이 머리를 돌려요

while -250 <= t.xcor() <= 250 and -250 <= t.ycor() <= 250:  #벽에 부딛힐 때까지 걸어갈거에요
    t.fd(1)  #1만큼씩 걸어갈거에요

while True:  #무한반복!

    ang = t.heading()  #현재 거북이의 각도를  ang에 저장해요

    if 0 <= ang <= 45 or 135 <= ang <= 180:  #만약 0~45 or 135~180 각도 안에 ang이 존재 하는 경우
        t.setheading(180 - ang)  #머리를 180-ang 만큼 돌려서
        t.fd(
            1
Example #59
0
def banner(s, color=TEXTCOLOR):
    turtle.home()
    turtle.color(color)
    turtle.write(s, True, align='center', font=('Arial', 48, 'italic'))
    time.sleep(3)
    turtle.undo()
 def do_home(self, args):
     'Return turtle to the home postion:  HOME'
     t.home()