当前位置: 首页>>代码示例>>Python>>正文


Python turtle.Turtle类代码示例

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


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

示例1: __init__

 def __init__(self, lmbda, mu, queue, server, speed):
     """
     Arguments:
         lmbda: arrival rate (float)
         interarrivaltime: a randomly sampled interarrival time (negative exponential for now)
         mu: service rate (float)
         service: a randomly sampled service time (negative exponential for now)
         queue: a queue object
         shape: the shape of our turtle in the graphics (a circle)
         server: a server object
         served: a boolean that indicates whether or not this player has been served.
         speed: a speed (integer from 0 to 10) to modify the speed of the graphics
         balked: a boolean indicating whether or not this player has balked (not actually needed for the base Player class... maybe remove... but might be nice to keep here...)
     """
     Turtle.__init__(self)  # Initialise all base Turtle attributes
     self.interarrivaltime = randexp(lmbda)
     self.lmbda = lmbda
     self.mu = mu
     self.queue = queue
     self.served = False
     self.server = server
     self.servicetime = randexp(mu)
     self.shape('circle')
     self.speed(speed)
     self.balked = False
开发者ID:ByronKKing,项目名称:Simulating_Queues,代码行数:25,代码来源:graphicalMM1.py

示例2: __init__

 def __init__(self, distance, color, speed):
     Turtle.__init__(self)
     self.pencolor(color)
     self.speed = speed
     self.penup()
     self.forward(distance)
     self.pendown()
开发者ID:ethanwhite,项目名称:assets,代码行数:7,代码来源:object-raptor-2.py

示例3: init_drawman

def init_drawman():
    global t, x_current, y_current
    t=Turtle()
    t.penup()
    x_current = 0
    y_current = 0
    t.goto(x_current,y_current)
开发者ID:Elodia-Elwen,项目名称:kpk2016,代码行数:7,代码来源:drawman.py

示例4: __init__

 def __init__(self, bilddatei, game):
     Turtle.__init__(self, bilddatei)
     self.game = game
     self.penup()
     self.speed(0)
     self.onclick(self.hit)
     self.start()
开发者ID:s-kimmer,项目名称:tesp2016,代码行数:7,代码来源:py_moorhuhn.py

示例5: main

def main():
    global screen
    screen = Screen()
    screen.colormode(255)
    p = Turtle()
    p.ht()
    screen.tracer(75,0)
    u = doit1(6, Turtle(undobuffersize=1))
    s = doit2(7, Turtle(undobuffersize=1))
    t = doit3(5, Turtle(undobuffersize=1))
    v = doit4(6, Turtle(undobuffersize=1))
    w = doit5(5, Turtle(undobuffersize=1))
    a = clock()
    while True:
        done = 0
        for b in u,s,t,v,w:
            try:
                next(b)
            except:
                done += 1
        if done == 5:
            break

    screen.tracer(1,10)
    b = clock()
    return "runtime: {0:.2f} sec.".format(b-a)
开发者ID:1c71,项目名称:Program-Practice,代码行数:26,代码来源:tdemo_another_forest.py

示例6: __init__

    def __init__(self, start=(10,10), end=(160,160),
                 width=200, height=200):
        Turtle.__init__(self)
        self.hideturtle()
        self.screen.bgcolor("blue")
        self.screen.setworldcoordinates(-DISTANCE, -DISTANCE,
                                        DISTANCE+width,
                                        DISTANCE+height)

        self.screen.tracer(30,0)
        self.pensize(5)
        self.color("white", "black")
        lab = {start} 
        while True:
            new_points = set()
            for point in lab:
                x,y = map(add, point, choice(WAYS))
                if (0 <= x <= width and
                    0 <= y <= height and
                    (x,y) not in lab and
                    (x,y) not in new_points):
                    self.penup()
                    self.goto(*point)
                    self.pendown()
                    self.goto(x,y)
                    new_points.add((x,y))
            if new_points or end not in lab:
                lab |= new_points
            else:
                break
        self.mark_targets(start, end)
        self.maze_map = lab
        self.start = start
        self.end = end
        print("KONEC")
开发者ID:a1ip,项目名称:my_check,代码行数:35,代码来源:bludiste.py

示例7: draw_figures

def draw_figures(figures):
    for figure in figures:
        t = Turtle()
        t.speed('slow')
        figure.draw_figure(t)

    done()
开发者ID:wencakisa,项目名称:Python-Dev,代码行数:7,代码来源:draw.py

示例8: LSystem

class LSystem(object):


    def __init__(self):
        self.turtle = Turtle()

    def reset(self):
        self.turtle.reset()

    def set_lsystem(self,lsystem):
        self.axiom,self.rules,self.angle = lsystem
        self.segment_length=5         


    def generate(self,generations_num): 
        def generate_help(start): 
             for e in start: 
                for r in self.rules.get(e,e):
                    yield r 
        if generations_num==0: return self.axiom
        return generate_help(self.generate(generations_num-1))     
                                                                
    def draw(self,generations,chunk_size):
        iterable = interpret(self.turtle,self.generate(generations),self.angle)
        l=[]
        for e in iterable:
            l.append(e)
            if len(l)==chunk_size:
                yield l
                l=[]
        if l: yield l
开发者ID:gromozeka1980,项目名称:kivy_contest_2014,代码行数:31,代码来源:lsystem.py

示例9: __init__

 def __init__(self):
     Turtle.__init__(self)
     self.up()
     self.setheading(random.randrange(360))
     self.setpos(random.randrange(-200,200),random.randrange(-200,200))
     self.down()
     self.newHead = None
     Schooler.swarm.append(self)
开发者ID:Hndrx616,项目名称:Python-src-redact,代码行数:8,代码来源:fishSwarm.py

示例10: init_drawman

def init_drawman():
    global x_current, y_current, t, _drawman_scale
    t=Turtle()
    t.penup()
    x_current=0
    y_current=0
    t.goto(x_current,y_current)
    drawman_scale(default_scale) # функция задает масштаб по умолчанию
开发者ID:BudykinaSV,项目名称:KPK_2016,代码行数:8,代码来源:proba.py

示例11: test_segments_stored

    def test_segments_stored(self):
        """With branching, some points exist"""
        my_turtle = Turtle()
        my_turtle.speed(0)
        my_tree = Tree()
        my_tree.draw(my_turtle, max_depth=1)

        self.assertTrue(len(my_tree.segments) > 0, "Some segments should be stored")
开发者ID:mpclemens,项目名称:python-explore,代码行数:8,代码来源:Tree.py

示例12: init_drawman

def init_drawman():
    global t, x_current, y_current, _drawman_scale
    t=Turtle()
    t.penup()
    x_current = 0
    y_current = 0
    t.goto(x_current, y_current)
    drawman_scale(default_scale)
开发者ID:tuhbatshina,项目名称:kpk_Python,代码行数:8,代码来源:Drawman.py

示例13: main

def main():
    dimension = int(input('Enter dimension: '))

    t = Turtle()
    t.speed('fastest')
    t.pensize(3)

    draw_table(dimension, 50, t, -200, 300)
开发者ID:wencakisa,项目名称:Softuni-Python3,代码行数:8,代码来源:chess.py

示例14: __init__

 def __init__(self, col, row):
     Turtle.__init__(self)
     self.speed(0)
     self.pu()
     self.shape("square")
     self.color("black", "")
     self.shapesize((BLOCKWIDTH-1)/20., (BLOCKWIDTH-1)/20., 1)
     self.goto(-COLUMNS*BLOCKWIDTH/2+14+col*BLOCKWIDTH, ROWS*BLOCKWIDTH/2 - 14 - row*BLOCKWIDTH)
开发者ID:DestinyHe,项目名称:python-turtle-demo,代码行数:8,代码来源:pytetris.py

示例15: test_points_stored

    def test_points_stored(self):
        """After one iteration, as least a trunk segment should be stored"""
        my_turtle = Turtle()
        my_turtle.speed(0)
        my_tree = Tree()
        my_tree.draw(my_turtle, max_depth=1)
        # whitebox

        self.assertTrue(len(my_tree._points) > 0, "Some points should be stored")
开发者ID:mpclemens,项目名称:python-explore,代码行数:9,代码来源:Tree.py


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