Python turtle 模块,forward() 实例源码

我们从Python开源项目中,提取了以下17个代码示例,用于说明如何使用turtle.forward()

项目:MyKnowledge    作者:guofei9987    | 项目源码 | 文件源码
def Tick():
    # ?????????
    t = datetime.datetime.today()
    second = t.second + t.microsecond * 0.000001
    minute = t.minute + second / 60.0
    hour = t.hour + minute / 60.0
    secHand.setheading(6 * second)
    minHand.setheading(6 * minute)
    hurHand.setheading(30 * hour)

    turtle.tracer(False)
    printer.forward(65)
    printer.write(Week(t), align="center",
                  font=("Courier", 14, "bold"))
    printer.back(130)
    printer.write(Date(t), align="center",
                  font=("Courier", 14, "bold"))
    printer.home()
    turtle.tracer(True)

    turtle.ontimer(Tick, 100)  # 100ms?????tick
项目:monty    作者:shoeffner    | 项目源码 | 文件源码
def draw_world(curvature_step=0):
    if curvature_step > 0:
        villages = 360 // 4 // curvature_step
    else:
        villages = 5

    for i in range(villages):
        prepare_drawing()
        draw_house()
        finish_drawing()

        turtle.right(curvature_step)
        turtle.forward(LENGTH * 11)

        for j in range(3):
            prepare_drawing()
            draw_tree(3 + j % 2 * 2)
            finish_drawing()

            turtle.right(curvature_step)
            turtle.forward(LENGTH * 3)

        turtle.forward(LENGTH)
项目:L-Systems-Compiler-And-Renderer    作者:Mizzlr    | 项目源码 | 文件源码
def draw(self):
        "draws the lsystem on the screen"
        stack = []
        tt.penup()
        tt.setpos(0, -200)
        tt.seth(90)
        tt.pendown()

        print "Drawing the lsystem ..."
        for i, codebit in enumerate(self.generation[-1]):

            if codebit in ['F', 'A', 'B']:
                tt.forward(self.length)
                print '[ FRWD ] ', codebit
            elif codebit == '+':
                tt.right(self.angle)
                print '[ RGHT ] ', codebit
            elif codebit == '-':
                tt.left(self.angle)
                print '[ LEFT ] ', codebit
            elif codebit == '[':
                stack.append((tt.pos(), tt.heading()))
                print '[ PUSH ] ', (tt.pos(), tt.heading())
            elif codebit == ']':
                position,heading = stack.pop()
                print '[ POP  ] ', (position, heading)
                tt.penup()
                tt.goto(position)
                tt.seth(heading)
                tt.pendown()
            else:
                print '[ NOP  ] ', codebit

            if self.save_every_frame:
                self.save(frame=i)

        print "Done drawing"
        print "Saving file as %s.jpg" % self.name,
        self.save()
        print "Done"
项目:MyKnowledge    作者:guofei9987    | 项目源码 | 文件源码
def Skip(step):
    turtle.penup()
    turtle.forward(step)
    turtle.pendown()
项目:MyKnowledge    作者:guofei9987    | 项目源码 | 文件源码
def mkHand(name, length):
    # ??Turtle???????Turtle
    turtle.reset()
    Skip(-length * 0.1)
    turtle.begin_poly()
    turtle.forward(length * 1.1)
    turtle.end_poly()
    handForm = turtle.get_poly()
    turtle.register_shape(name, handForm)
项目:MyKnowledge    作者:guofei9987    | 项目源码 | 文件源码
def SetupClock(radius):
    # ??????
    turtle.reset()
    turtle.pensize(7)
    for i in range(60):
        Skip(radius)
        if i % 5 == 0:
            turtle.forward(20)
            Skip(-radius - 20)
        else:
            turtle.dot(5)
            Skip(-radius)
        turtle.right(6)
项目:nautical-combat    作者:horstjens    | 项目源码 | 文件源码
def zweig(laenge = 10, winkel=30, divisor=2):
    if laenge < 2:
        return
    turtle.forward(laenge)
    turtle.left(winkel)
    zweig(laenge//divisor, winkel, divisor)
    turtle.right(winkel*2)
    zweig(laenge//divisor, winkel, divisor)
    turtle.left(winkel)
    turtle.penup()
    turtle.forward(-laenge)
    turtle.pendown()
项目:Leetcode    作者:staticor    | 项目源码 | 文件源码
def moveTurtles(turtleList,dist,angle):
    for turtle in turtleList:   # Make every turtle on the list do the same actions.
        turtle.forward(dist)
        turtle.right(angle)
项目:IPC_2017-1    作者:jucimarjr    | 项目源码 | 文件源码
def draw_star(x, y, side):
    star_angle = 360.0/6
    left_angle = star_angle * 2
    tu.penup()
    tu.goto(x, y)
    tu.pendown()
    for i in range(6):
        tu.forward(side)
        tu.right(star_angle)
        tu.forward(side)
        tu.left(left_angle)
项目:Scheme    作者:StephenK1998    | 项目源码 | 文件源码
def tscheme_forward(n):
    """Move the turtle forward a distance N units on the current heading."""
    _check_nums(n)
    _tscheme_prep()
    turtle.forward(n)
    return okay
项目:Charon    作者:forrestchang    | 项目源码 | 文件源码
def tscheme_forward(n):
    """Move the turtle forward a distance N units on the current heading."""
    _check_nums(n)
    _tscheme_prep()
    turtle.forward(n)
    return okay
项目:monty    作者:shoeffner    | 项目源码 | 文件源码
def draw_tree(h):
    if h == 0:
        return
    turtle.forward(LENGTH * h)
    turtle.left(ANGLE)
    draw_tree(h - 1)
    turtle.right(2 * ANGLE)
    draw_tree(h - 1)
    turtle.left(ANGLE)
    turtle.backward(LENGTH * h)
项目:monty    作者:shoeffner    | 项目源码 | 文件源码
def draw_house():
    height = 5
    width = 7
    roofside = (width ** 2 / 2) ** (1 / 2)
    turtle.forward(LENGTH * height)  # left wall
    turtle.right(45)  # roof
    turtle.forward(LENGTH * roofside)
    turtle.right(90)
    turtle.forward(LENGTH * roofside)
    turtle.right(45)
    turtle.forward(LENGTH * height)  # right wall
    turtle.right(90)
    turtle.forward(LENGTH * width)  # bottom line
    turtle.right(90)
项目:thinkcspy-studios    作者:LaunchCodeEducation    | 项目源码 | 文件源码
def draw_square(length, turtle):
    for side in range(4):
        turtle.forward(length)
        turtle.left(90)
项目:SchemeInterpreter    作者:GrantHiggins16    | 项目源码 | 文件源码
def tscheme_forward(n):
    """Move the turtle forward a distance N units on the current heading."""
    _check_nums(n)
    _tscheme_prep()
    turtle.forward(n)
    return okay
项目:python-practice    作者:VamsiSangam    | 项目源码 | 文件源码
def printPolygon(sides, sideLength):
    for steps in range(sides):
        turtle.forward(sideLength)
        turtle.right(360 / sides)
    return
项目:python-practice    作者:VamsiSangam    | 项目源码 | 文件源码
def main():
    length = 128
    sides = 3

    while length != 1:
        printPolygon(sides, length)
        turtle.forward(length / 4)
        sides += 1
        length /= 2

    return

# main()