本文整理汇总了Python中turtle.Turtle.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Turtle.__init__方法的具体用法?Python Turtle.__init__怎么用?Python Turtle.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类turtle.Turtle
的用法示例。
在下文中一共展示了Turtle.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import __init__ [as 别名]
def __init__(self, distance, color, speed):
Turtle.__init__(self)
self.pencolor(color)
self.speed = speed
self.penup()
self.forward(distance)
self.pendown()
示例2: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import __init__ [as 别名]
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")
示例3: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import __init__ [as 别名]
def __init__(self, bilddatei, game):
Turtle.__init__(self, bilddatei)
self.game = game
self.penup()
self.speed(0)
self.onclick(self.hit)
self.start()
示例4: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import __init__ [as 别名]
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
示例5: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import __init__ [as 别名]
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)
示例6: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import __init__ [as 别名]
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)
示例7: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import __init__ [as 别名]
def __init__(self, picfile, action):
Turtle.__init__(self)
self.getscreen().register_shape(picfile)
self.shape(picfile)
def _action(x,y):
action()
self.onclick(_action)
self.pu()
self.speed(0)
示例8: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import __init__ [as 别名]
def __init__(self, distance, color, speed, angle):
Turtle.__init__(self)
self.pencolor(color)
self.speed = speed
self.angle = angle
self.penup()
self.forward(distance)
self.pendown()
self.left(90)
示例9: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import __init__ [as 别名]
def __init__(self, m, x, v, gravSys, shape):
Turtle.__init__(self, shape)
gravSys.planets.append(self)
self.gravSys = gravSys
self.dt = self.gravSys.dt
self.penup()
self.m = m
self.setpos(x)
self.vel = v
self.pendown()
示例10: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import __init__ [as 别名]
def __init__(self, m, x, v, gravSys, shape):
Turtle.__init__(self, shape=shape)
self.penup()
self.m = m
self.setpos(x)
self.v = v
gravSys.planets.append(self)
self.gravSys = gravSys
self.resizemode("user")
self.pendown()
示例11: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import __init__ [as 别名]
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
self.velocity = Vec2D(0,0)
self.neighbordist = 200
self.viewangle = 45
self.neighbors = []
Schooler.swarm.append(self)
示例12: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import __init__ [as 别名]
def __init__(self, bilddatei, game):
Turtle.__init__(self, bilddatei)
# self.game = game
self.penup()
self.speed(0)
self.u = 0.0
self.v = 0.0
self.goon = True
# self.game = game
self.rot = 0
self.screenWidth = 1920 #width laptop screen
# self.screenHeight = 745
# print("crosshairint")
self.cc = 0
示例13: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import __init__ [as 别名]
def __init__(self, size, shape="arrow", clickable=True):
Turtle.__init__(self)
self.size = size
self.pu()
self.shape(shape)
self.resizemode("user")
self.turtlesize(size,size,3)
self.clicktime = -1
if clickable:
self.onclick(self.turnleft, 2)
self.onclick(self.turnright, 3)
self.onclick(self.store, 1)
self.ondrag(self.move, 1)
self.onrelease(self.match, 1)
示例14: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import __init__ [as 别名]
def __init__(self,name = "", shape = "turtle", visible = False, colors = None):
Turtle.__init__(self, shape, visible=visible)
self._root = self._screen._root
self.cv = Turtle._screen._canvas
if name =="":
self._name = self.randomString(8) # zufälliges setzen ohne Prüfung
else:
self.name = name # über die Setter wird geprüft
if colors == None:
self.color("black", "pink")
else:
self.color(colors[0],colors[1])
self._keys = []
self._ground = self._screen
示例15: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import __init__ [as 别名]
def __init__(self, c, r, tritype):
Turtle.__init__(self, shape="triangle")
self.c = c
self.r = r
self.speed(0)
self.pencolor(0, 0, 0)
if tritype == 1:
self.basecolor = (1.0, 0.80392, 0.0)
self.f = -1
self.left(30)
else:
self.basecolor = (0.43137, 0.43137, 1.0)
self.f = 1
self.left(90)
self.fillcolor(self.basecolor)
self.pu()
self.goto(c * A, r * A * 3 ** 0.5 / 3)
self.shapesize(SHS, SHS, 1)
self.D = self.distance(0, 0)
self.e = (1 / self.D) * self.pos()