• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python turtle.goto函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中turtle.goto函数的典型用法代码示例。如果您正苦于以下问题:Python goto函数的具体用法?Python goto怎么用?Python goto使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了goto函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: line

def line(a1,b1,a2,b2,c):
    turtle.pu()
    turtle.goto(a1,b1)
    turtle.color(c)
    turtle.pd()
    turtle.pensize(10)
    turtle.goto(a2,b2)
开发者ID:DCoelhoM,项目名称:Tic-Tac-Toe-Python,代码行数:7,代码来源:Tic-Tac-Toe_by_DCM.py


示例2: rectangle

def rectangle(length = 50, width = 30, x = 0, y = 0, color = 'black', fill = False):
    turtle.pensize(3)
    turtle.speed('fastest')
    turtle.hideturtle()
    if fill == True:
        turtle.color(color)
        for i in range(width): 
            turtle.setposition(x, (y+i))
            turtle.pendown()
            turtle.setposition((x+length), (y+i))
            turtle.penup()
    else:
        turtle.penup()
        turtle.goto(x,y)
        turtle.color(color)
        turtle.pendown()
        turtle.forward(length)
        turtle.left(90)
        turtle.forward(width)
        turtle.left(90)
        turtle.forward(length)
        turtle.left(90)
        turtle.forward(width)
        turtle.left(90)
        turtle.penup()

    return
开发者ID:JakenHerman,项目名称:python-homework,代码行数:27,代码来源:GraphicsAndPatternLibrary.py


示例3: drawLine

    def drawLine(self,color,coord1,coord2): 
        """
        dessine une ligne entre deux coordonné sur la grille

        :param color: La couleur de la ligne
        :param coord1: La première coordonné en tuple (i,j,"joueur")
        :param coord2: La deuxième coordonné en tuple (i,j,"joueur")
        """
        if coord1[2] == coord2[2] and coord2[2] == "you":
            turtle.goto(38+coord1[1]*25,87-25*coord1[0])
        elif coord1[2] == coord2[2] and coord2[2] == "enemy":
            turtle.goto(-262+(25*coord1[1]),87-25*coord1[0])
        else:
            print('wrong player')
            return 0
        turtle.pensize(20)
        turtle.pencolor(color)
        if coord1[1] == coord2[1]: #Vertical
            turtle.pendown()
            turtle.setheading(270)
            turtle.fd((coord2[0]-coord1[0])*25)
        elif coord1[0] == coord2[0]: #horizontal
            turtle.pendown()
            turtle.setheading(0)
            turtle.fd((coord2[1]-coord1[1])*25)
        else:
            print('Ligne non Hori ou Vert')
            return 0
        turtle.penup()
        return 1
开发者ID:etiennedub,项目名称:battleship,代码行数:30,代码来源:interface.py


示例4: drawmountain

def drawmountain(x,y,color):
	t.up
	t.goto(x,y)
	t.down
	t.color(color)
	t.begin_fill()
	t.backward(200)
	t.right(120)
	t.backward(200)
	t.right(120)
	t.backward(200)
	t.right(120)
	t.end_fill()
	t.up

	t.goto(x-75,y+125)
	t.down
	t.color("White")
	t.begin_fill()
	t.backward(50)
	t.right(120)
	t.backward(50)
	t.right(120)
	t.backward(50)
	t.right(120)
	t.end_fill()
	t.up
开发者ID:ccasey645,项目名称:OldMachine,代码行数:27,代码来源:drawchristmas.py


示例5: entrance

def entrance(pointOne):
    turtle.goto(pointOne[0], pointOne[1] + 36)
    turtle.setheading(270)
    turtle.pendown()
    turtle.forward(15)
    turtle.penup()
    drawArrows()
开发者ID:JonSchwarz23,项目名称:Automaton,代码行数:7,代码来源:NoSaveAutomaton.py


示例6: draw_path

    def draw_path(self, positions):
        '''
        Draws the path given by a position list
        '''

        def position_to_turtle(pos):
            '''Converts a maze position to a turtle position'''
            return (home_x + _DRAW_SIZE * pos[0], home_y - _DRAW_SIZE * pos[1])

        # Get maze size
        width, height = self.size

        # Prepare turtle
        home_x = (-(_DRAW_SIZE * width) / 2) + (_DRAW_SIZE / 2)
        home_y = ((_DRAW_SIZE * height) / 2) - (_DRAW_SIZE / 2)

        turtle.showturtle()
        turtle.pencolor(_DRAW_PATH)

        # Move to star
        turtle.penup()
        turtle.goto(home_x, home_y)
        turtle.pendown()

        # Draw the path
        for pos in positions:
            turtle.goto(position_to_turtle(pos))
开发者ID:jcowgill,项目名称:cs-work,代码行数:27,代码来源:maze_base.py


示例7: main

def main():
    """
    Tous les phase du battleship passe par le main()
    et il sert de boucle principal car il est appelé à
    tous les 0.5 secondes
    """
    if i.phase == "PlaceShip":
        i.placeShip()
    elif i.phase == "Attack": # Nom fictif
        i.attack()
    elif i.phase == "win":
        print('Vous avez gagné!')
        turtle.goto(0,0)
        turtle.pencolor('black')
        turtle.write('Vous avez gagné!',align="center",font=("Arial",70, "normal"))
        i.phase = "exit"
    elif i.phase == "lose":
        print('Vous avez perdu!')
        turtle.goto(0,0)
        turtle.pencolor('black')
        turtle.write('Vous avez perdu!',align="center",font=("Arial",70, "normal"))
        i.phase = "exit"
    elif i.phase == "exit":
        turtle.exitonclick()
        return None
    else:
        print('out')

    turtle.ontimer(main,500)
开发者ID:etiennedub,项目名称:battleship,代码行数:29,代码来源:main.py


示例8: alpha_beta_helper

def alpha_beta_helper():
	global state, root, alpha_time
	initialize()
	print("PLEASE WAIT!!!")
	root = TreeNode(-1000)
	time1 = time.time()
	alpha_beta(root, 1, state)
	init_screen()
	drawLine()
	drawGrid()
	drawColumns()
	drawRows()
	caliberate()
	col = root.ans
	row = -1
	turtle.onscreenclick(goto)
	for i in range(4):
		if state[i][col] == 0:
			row = i
			break
	state[row][col] = 1
	drawDot(row, col, 1)
	var = (int)(input("Enter 1 to continue playing or 0 to stop."))
	time2 = time.time()
	alpha_time = time2-time1
	if(var == 1):
		turtle.clear()
		turtle.goto(0, 0)
		turtle.penup()
		turtle.right(270)
		alpha_beta_helper()
	else:
		write_analysis(3)
开发者ID:krnbatra,项目名称:AI-Assignments,代码行数:33,代码来源:assign2.py


示例9: draw_tree

def draw_tree(x,y):
    startPosX = x
    startPosY = y
    turtle.setpos(x,y)
    turtle.fillcolor("green")
    turtle.begin_fill()
    for i in range(0,4):
        x -=40
        y -=80
        turtle.goto(x,y)
        coords.append(turtle.pos())
        x += 20
        turtle.goto(x,y)
    bottomCorner = turtle.pos()
    x = startPosX
    y = startPosY
    turtle.setpos(x,y)
    for i in range(0,4):
        x +=40
        y -=80
        turtle.goto(x,y)
        coords.append(turtle.pos())
        x -= 20
        turtle.goto(x,y)
    turtle.goto(bottomCorner)
    turtle.end_fill()
开发者ID:nyep,项目名称:learning-prog,代码行数:26,代码来源:turtleTree+[WIP].py


示例10: roach

def roach(turt):
    #make moves a global variable
    global moves
    turt.pencolor(randrange(255),randrange(255),randrange(255))
    turtle.up()
    turtle.goto(0,0)
    turtle.down()
    #write the code for roach to go & turn
    while True:
        moves += 1
        turt_heading = randrange(0,361)
        turt.left(turt_heading)
        turt_length = randrange(0,31)
        turt.forward(turt_length)
        distance = dist(turt)
        #if statement to determine if the roach is outside the circle or inside
        #if inside, keep moving
        #if outside, stop moving
        #return coordinate
        if distance >= 200:
            break
    turt.up()
    moves += moves                      #accummulate total moves
    print(moves)
    return moves
开发者ID:khoanguyen0791,项目名称:cs170,代码行数:25,代码来源:Roach+Race+2.py


示例11: drawLine

def drawLine():
	turtle.penup()
	turtle.goto(-50, 300)
	turtle.pendown()
	turtle.write("Base Line", font=("Arial", 14, "normal"))
	turtle.color("red")
	turtle.forward(500)
开发者ID:krnbatra,项目名称:AI-Assignments,代码行数:7,代码来源:assign2.py


示例12: hands

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) )
开发者ID:slott56,项目名称:HamCalc-2.1,代码行数:27,代码来源:logoclok.py


示例13: draw_circle

def draw_circle(x,y,r,t):
    t.pu()
    t.goto(x+r,y)
    t.setheading(90)
    t.pd()
    t.circle(r)
    t.pu()
开发者ID:wraith1995,项目名称:persistentHomology,代码行数:7,代码来源:ph.py


示例14: drawCloud

def drawCloud(words, num = 20):
    """ Draws a wordcloud with 20 random words, sized by frequency found in 
    the WORDS dictionary. """
    t.reset()
    t.up()
    t.hideturtle()
    topCounts = sorted([words[word] for word in list(words.keys()) if len(word) > 3])
    largest = topCounts[0]
    normalized_counts = {}
    for item in list(words.keys()):
        if len(item) > 3:
            newSize = int(float(words[item]) / largest * 24)
            normalized_counts[item] = newSize
    
    size = t.screensize()
    width_dim = (int(-1 * size[0] / 1.5), int(size[0] / 2))
    height_dim = (int(-1 * size[1] / 1.5), int(size[1] / 1.5))
    

    for item in random.sample(list(normalized_counts.keys()), num):
        t.goto(random.randint(*width_dim), random.randint(*height_dim))
        t.color(random.choice(COLORS))
        try:
            t.write(item, font = ("Arial", int(normalized_counts[item]), "normal"))
        except:
            try:
                t.write(str(item, errors = 'ignore'), font = ("Arial", int(normalized_counts[item]), "normal"))
            except:
                pass
开发者ID:cs10,项目名称:twitter,代码行数:29,代码来源:wordcloud.py


示例15: circle

def circle(x,y,size):
	turtle.pu()
	turtle.goto(x,y)
	turtle.pd()
	turtle.begin_fill()
	turtle.circle(size)
	turtle.end_fill()
开发者ID:ameen16-meet,项目名称:MEET-YL1,代码行数:7,代码来源:ameenproject.py


示例16: f

def f(l, n):
	t.up()
	t.goto( - l / 2, l / 3 )
	t.down()
	for i in rang(3):
		vk(l, n)
		t.right(120)
开发者ID:richardjuan,项目名称:nmt,代码行数:7,代码来源:vonKoch.py


示例17: line

def line(a, b, x, y):
    "Draw line from `(a, b)` to `(x, y)`."
    import turtle
    turtle.up()
    turtle.goto(a, b)
    turtle.down()
    turtle.goto(x, y)
开发者ID:grantjenks,项目名称:free_python_games,代码行数:7,代码来源:utils.py


示例18: printwin

def printwin(turtle):
  turtle.stamp()
  turtle.hideturtle()
  turtle.penup()
  turtle.goto(0,0)
  turtle.color("green")
  turtle.write("You Win!",font=("Arial",30), align = "center")
开发者ID:LRBeaver,项目名称:PythonGameDev_Trinket,代码行数:7,代码来源:helpercode.py


示例19: curva

def curva(simbolos,identificador,linea):
  p1= obtener_punto(1,identificador,simbolos)
  p2= obtener_punto(2,identificador,simbolos)
  
  x1 = int (obtener_x(p1,simbolos))
  y1 = int (obtener_y(p1,simbolos))
  x2 = obtener_x(p2,simbolos)
  y2 = obtener_y(p2,simbolos)  

  rotar = obtener_rotar(identificador, simbolos,linea)
  escalar = obtener_escalar(identificador, simbolos,linea)
  relleno = obtener_color(obtener_relleno(identificador,simbolos,linea))  
  turtle.color(relleno)

  tx = obtener_tx(identificador, simbolos,linea)
  ty = obtener_ty(identificador, simbolos,linea)
  potencia = obtener_potencia(identificador,simbolos)
  
  #Trasladar recta
  x1 = int(x1*44 + tx*44)
  x2 = int(x2*44 + tx*44)
  y1 = y1*44 + ty*44
  y2 = y2*44 + ty*44  
  turtle.penup()
  for x in range(x1,x2):
  	turtle.goto(x+(44), (x+(44))**potencia)
  	turtle.pendown()
开发者ID:joenco,项目名称:compiladorg,代码行数:27,代码来源:figuras.py


示例20: drawCircleAt

def drawCircleAt(turtleX, turtleY, circleSize):
    turtle.penup()
    turtle.goto(turtleX,turtleY)
    turtle.pendown()
    turtle.begin_fill()
    turtle.circle(circleSize)
    turtle.end_fill()
开发者ID:cparker,项目名称:pythonclub,代码行数:7,代码来源:one.py



注:本文中的turtle.goto函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python turtle.heading函数代码示例发布时间:2022-05-27
下一篇:
Python turtle.getscreen函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap