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

Python turtle.ycor函数代码示例

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

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



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

示例1: d

def d(fill=False):
    '''draws a capital D'''
    turtle.setheading(0)
    if fill: bf()
    fd(20)
    circle(20, 90)
    fd(70)
    circle(20, 90)
    fd(20)
    lt(90)
    fd(110)
    lt(90)
    if fill: ef()
    pu()
    turtle.goto(turtle.xcor() + 10, turtle.ycor() + 10)
    pd()
    cfc = fc()
    fc(turtle.getscreen().bgcolor())
    bf()
    fd(10)
    circle(10, 90)
    fd(70)
    circle(10, 90)
    fd(10)
    lt(90)
    fd(90)
    ef()
    lt(90)
    pu()
    turtle.goto(turtle.xcor() + 40, turtle.ycor() - 10)
    pd()
    fc(cfc)
开发者ID:BoroDojo,项目名称:borodojo-python,代码行数:32,代码来源:fredx.py


示例2: verificarPos

    def verificarPos(self):
        """
        Desc: Método para verificar se a posição e sentido da tartaruga é igual ao inicial
        Use getPos() para pegar o inicial

        Printa: String = Erro
        Retorna: Boolean = True (caso esteja ok) ou False (caso não)

        Exemplo:
        cb.getPos()
        cb.casa(25, 50, 30)
        cb.verificarPos()
        """

        self._retorno = True

        if (round(turtle.xcor()) != self.turtlePosX) or (round(turtle.ycor()) != self.turtlePosY):
            print("A posição atual da tartaruga difere da inicial ({0}, {1})\nEla está em: ({2}, {3})".format(str(self.turtlePosX),
                  str(self.turtlePosY),
                  str(round(turtle.xcor())),
                  str(round(turtle.ycor()))))
            self._retorno = False
        if turtle.heading() != self.turtleDir:
            print("A direção atual da tartaruga difere da inicial (" + str(self.turtleDir) + ")\nEla está em:", str(turtle.heading()))
            self._retorno = False

        return self._retorno
开发者ID:SrMouraSilva,项目名称:Academic-Projects,代码行数:27,代码来源:cb.py


示例3: checkybound

def checkybound():
	if turtle.ycor() > (wn.screensize()[0]/2):
		return 3
	elif turtle.ycor() < (wn.screensize()[0]/-2):
		return 4
	else:
		return 0
	time.sleep(1)
开发者ID:malsf21,项目名称:dmcs,代码行数:8,代码来源:keyboard.py


示例4: gotoandprint

 def gotoandprint(x, y):
     turtle.goto(x, y)
     #time.sleep(10)
     print()
     print("Set hook:")
     print(turtle.xcor(), turtle.ycor())
     x=turtle.xcor()
     y=turtle.ycor()
     coordinate=[x,y]
     return coordinate
开发者ID:helpmoeny,项目名称:pythoncode,代码行数:10,代码来源:proj11old.py


示例5: tree

def tree():
    '''draw a tree'''
    oc = color()
    fc('saddle brown')
    bf()
    turtle.goto(turtle.xcor()+20,turtle.ycor())
    turtle.goto(turtle.xcor(),turtle.ycor()+80)
    turtle.goto(turtle.xcor()-20,turtle.ycor())
    turtle.goto(turtle.xcor(),turtle.ycor()-80)
    ef()
    fc('dark green')
    color('dark green')
    pu()
    turtle.goto(turtle.xcor()+10,turtle.ycor()+80)
    pd()
    bf()
    circle(20)
    ef()
    turtle.goto(turtle.xcor()-20,turtle.ycor()-20)
    bf()
    circle(20)
    ef()
    pu()
    turtle.goto(turtle.xcor()+40,turtle.ycor())
    pd()
    bf()
    circle(20)
    ef()
    pu()
    turtle.goto(turtle.xcor()-30,turtle.ycor()-60)
    pd()
    color(oc[0])
    fc(oc[1])
开发者ID:BoroDojo,项目名称:borodojo-python,代码行数:33,代码来源:fredx.py


示例6: a

def a(fill=False):
    '''draws a capital A.'''
    turtle.setheading(0)
    if fill: bf()
    fd(10)
    turtle.goto(turtle.xcor() + 5, turtle.ycor() + 40)
    fd(10)
    turtle.goto(turtle.xcor() + 5, turtle.ycor() - 40)
    fd(10)
    turtle.goto(turtle.xcor() - 15, turtle.ycor() + 110)
    turtle.setx(turtle.xcor() - 10)
    turtle.goto(turtle.xcor() - 15, turtle.ycor() - 110)
    if fill: ef()
    pu()
    turtle.goto(turtle.xcor() + 17, turtle.ycor() + 50)
    pd()
    if fill:
        cfc = fc()
        fc(turtle.getscreen().bgcolor())
        bf()
    fd(6)
    turtle.goto(turtle.xcor() - 3, turtle.ycor() + 40)
    turtle.goto(turtle.xcor() - 3, turtle.ycor() - 40)
    if fill:
        ef()
        fc(cfc)
    pu()
    turtle.goto(turtle.xcor() + 33, turtle.ycor() - 50)
    pd()
开发者ID:BoroDojo,项目名称:borodojo-python,代码行数:29,代码来源:fredx.py


示例7: main

def main():
        drawEnd = False
        while drawEnd == False:
                if turtle.xcor() < xEndPoint and turtle.ycor() < yEndPoint:
                        randDir = None
                        while randDir == None:
                                randDir = randomDirection()
                        
                        moveTurtle(turtle, randDir)
                
                elif turtle.xcor() < xEndPoint:
                        moveTurtle(turtle, EAST)
                elif turtle.ycor() < yEndPoint:
                        moveTurtle(turtle, NORTH)
                else:
                        drawEnd = True
开发者ID:lekamj,项目名称:turtlePath,代码行数:16,代码来源:pathCreator.py


示例8: printwin

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


示例9: passeio

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
开发者ID:ernestojfcosta,项目名称:IPRP,代码行数:35,代码来源:grelha.py


示例10: drawHouse

def drawHouse(wallSize):

    """
    This is the function for drawing house which takes
    wall size as a input.
    :pre: (relative) pos (0,0), heading (east), right
    :post: (relative) pos (wallSize,0), heading (north), up
    :return: total wood required to built the house.
    """
    turtle.down()
    turtle.forward(wallSize)
    turtle.left(90)
    turtle.forward(wallSize)
    maxX = turtle.xcor()
    turtle.left(45)
    turtle.forward(wallSize / math.sqrt(2))
    maxY = turtle.ycor()
    turtle.left(90)
    turtle.forward(wallSize / math.sqrt(2))
    turtle.left(45)
    turtle.forward(wallSize)
    turtle.left(90)
    turtle.forward(wallSize)
    turtle.up()
    return 2 * (wallSize + wallSize / math.sqrt(2))
开发者ID:RIT-2015,项目名称:CPS,代码行数:25,代码来源:new_draw.py


示例11: draw_star

def draw_star(size, color):
    # from center move to left vertex
    tt.setpos(tt.xcor()-size/2.0, tt.ycor()+size/2.0/math.tan(math.radians(72.0))) 

    tt.fillcolor(color)
    tt.begin_fill()

    for i in range(5):
        tt.forward(size/2.0/(1+math.sin(math.radians(18))))
        tt.left(72)
        tt.forward(size/2.0/(1+math.sin(math.radians(18))))
	tt.right(180-36)

    tt.end_fill()

    # back to center
    tt.setpos(tt.xcor()+size/2.0, tt.ycor()-size/2.0/math.tan(math.radians(72.0)))
开发者ID:zhuoliu0920,项目名称:python-projects,代码行数:17,代码来源:drawingflag.py


示例12: collision_check

	def collision_check(self, turtle):
		self._turtlex = turtle.xcor()
		self._turtley = turtle.ycor()
		self._dist = (((self._x1 - self._x2)**2 + (self._y1 - self._y2)**2)**0.5)
		self._dist2 = (((self._x1 - self._turtlex)**2 + (self._y1 - self._turtley)**2)**0.5)
		self._dist3 = (((self._turtlex - self._x2)**2 + (self._turtley - self._y2)**2)**0.5)
		if(self._dist2 + self._dist3 == self._dist): 
			return True
开发者ID:SkeemoGloves,项目名称:CM4K,代码行数:8,代码来源:wall.py


示例13: pox

def pox(turtle, x, y, n=10):
    origx = turtle.xcor()
    origy = turtle.ycor()
    turtle.penup()
    for i in range(n):
        random_location(turtle, x, y, True)
        turtle.dot(random.randint(3, 10), random_color())
        turtle.setpos(origx, origy)
    turtle.pendown()
开发者ID:gillenme,项目名称:fall2013turtlehack,代码行数:9,代码来源:turtlehack.py


示例14: rectangle

def rectangle(length, width, x = None, y = None, color = "black", fill = False):
	wasDown = turtle.isdown()
	turtle.up()
	if x is not None and y is not None:
		turtle.setpos(x, y)
	if wasDown:
		turtle.down()
	if fill:
		turtle.color(color, color)
		turtle.begin_fill()
	else:
		turtle.pencolor(color)
	turtle.goto(turtle.xcor() + length, turtle.ycor())
	turtle.goto(turtle.xcor(), turtle.ycor() + width)
	turtle.goto(turtle.xcor() - length, turtle.ycor())
	turtle.goto(turtle.xcor(), turtle.ycor() - width)
	if fill:
		turtle.end_fill()
开发者ID:rayman456,项目名称:Python,代码行数:18,代码来源:GraphicsFunctions.py


示例15: random_location

def random_location(turtle, x, y, relative=False):
  if not relative:
  	random_x = random.randint(-x, x)
  	random_y = random.randint(-y, y)
  	turtle.setpos(random_x, random_y)
  else:
  	random_x = turtle.xcor() + random.randint(-x, x)
  	random_y = turtle.ycor() + random.randint(-y, y)
  	turtle.setpos(random_x, random_y)
开发者ID:JaguarPhD,项目名称:fall2013turtlehack,代码行数:9,代码来源:turtlehack.py


示例16: sinus

def sinus(amplituda, perioda):
    deleni = 256   # počet díléčků pro periodu
    pocatekX = t.xcor()
    pocatekY = t.ycor()
    krok = perioda / deleni
    krokUhel = 2 * math.pi / deleni
    for i in range(deleni):
        t.goto(pocatekX + i * krok,
               pocatekY + amplituda * math.sin( i * krokUhel  ) )
开发者ID:tlapicka,项目名称:2014-2015.3A,代码行数:9,代码来源:zelva.py


示例17: spiral

def spiral(radius):
    xcor = turtle.xcor()
    ycor = turtle.ycor()
    speed = 1
    while True:
        turtle.forward(speed)
        turtle.left(10)
        speed += 1 * 0.01
        if turtle.distance(xcor, ycor) > radius:
            break
开发者ID:CoderDojoPotsdam,项目名称:projects,代码行数:10,代码来源:Spirale.py


示例18: draw_spiral

def draw_spiral(radius):
    original_xcor = t.xcor()
    original_ycor = t.ycor()
    speed = 1
    while True:
        t.forward(speed)
        t.left(10)
        speed += 0.1
        if t.distance(original_xcor, original_ycor) > radius:
            break
开发者ID:silentShadow,项目名称:CSC101,代码行数:10,代码来源:turtle-spirals.py


示例19: joonistaLipp

def joonistaLipp(riik, lipud=lipud):
    värvid = lipud[riik]
    turtle.pendown()
    for värv in värvid:
        turtle.begin_fill()
        turtle.fillcolor(värv)
        turtle.forward(100)
        turtle.right(90)
        turtle.forward(20)
        turtle.right(90)
        turtle.forward(100)
        turtle.right(90)
        turtle.forward(20)
        turtle.end_fill()
        turtle.sety(turtle.ycor()-20)
        turtle.right(90)
    turtle.penup()
    turtle.sety(turtle.ycor()+60)
    turtle.setx(turtle.xcor()+110)
开发者ID:Azelor,项目名称:pythons,代码行数:19,代码来源:14-C.py


示例20: gotoandprint

def gotoandprint(x, y):
    if -5 <= x <= 5 and 0 <= y <= -40:  # vertical - line 1
        krisha.reset()
        krisha.write("Game over", font=("Arial", 40, "normal"))
        print "error"

    elif -75 <= x <= 5 and -40 <= y <= -30:  # horizontal - line 2
        krisha.reset()
        krisha.write("Game over", font=("Arial", 40, "normal"))
        print "error"

    elif -75 <= x <= -65 and -40 <= y <= 75:  # vertical-  line 3
        krisha.reset()
        krisha.write("Game over", font=("Arial", 40, "normal"))
        print "error"

    elif -75 <= x <= 75 and 65 <= y <= 75:  # horizontal - line 4
        krisha.reset()
        krisha.write("Game over", font=("Arial", 40, "normal"))
        print "error"

    elif 65 <= x <= 75 and -105 <= y <= 75:  # vertical - line 5
        krisha.reset()
        krisha.write("Game over", font=("Arial", 40, "normal"))
        print "error"

    elif -145 <= x <= 75 and -105 <= y <= -95:  # horizontal - line  6
        krisha.reset()
        krisha.write("Game over", font=("Arial", 40, "normal"))
        print "error"

    elif -145 <= x <= -135 and -105 <= y <= 145:  # vertical - line 7
        krisha.reset()
        krisha.write("Game over", font=("Arial", 40, "normal"))
        print "error"

    elif -145 <= x <= 145 and 135 <= y <= 145:  # horizontal - line 8
        krisha.reset()
        krisha.write("Game over", font=("Arial", 40, "normal"))
        print "error"

    elif 135 <= x <= 145 and -174 <= y <= 145:  # vertical - line 9
        krisha.reset()
        krisha.write("Game over", font=("Arial", 40, "normal"))
        print "error"

    #   # gotoresult = turtle.goto(x, y)
    #   # print(turtle.xcor(), turtle.ycor())
    #   # return gotoresult

    else:
        gotoresult = turtle.goto(x, y)
        print (turtle.xcor(), turtle.ycor())
        print (topPoint, bottomPoint)
        return gotoresult
开发者ID:knalavadi,项目名称:knalavadi,代码行数:55,代码来源:mazesun.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python turtle.Screen类代码示例发布时间:2022-05-27
下一篇:
Python turtle.xcor函数代码示例发布时间: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