def __init__(self, size, color, speed): Turtle.__init__(self) self.size = size turtle.begin_poly() turtle.fillcolor(color) turtle.speed(speed) turtle.penup() turtle.backward(50) turtle.fd(50) turtle.right(50) turtle.fd(50) turtle.rt(50) turtle.fd(50) turtle.rt(50) turtle.fd(50) turtle.rt(50) turtle.fd(50) turtle.rt(50) turtle.fd(50) turtle.rt(50) turtle.fd(50) turtle.pendown() turtle.end_poly() H = turtle.get_poly() turtle.register_shape("myFavouriteHexagon", H) turtle.shape("myFavouriteHexagon")
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")
def __init__(self, x, y): Turtle.__init__(self) self.penup() self.goto(x, y) self.shapesize(2, 8) self.color("black") self.shape("square")
def __init__(self): Turtle.__init__(self) self.level = 1 self.penup() self.hideturtle() self.goto(-280, 250) self.update()
def __init__(self, size, color): Turtle.__init__(self) self.shapesize = size turtle.shape("square") turtle.colormode(255) # turtle.color(color) '''
def __init__(self, window_width, window_height): # Set scale factor accordingly to display all the trajectories on the screen # (Using a planet with a low G and a gun with a high muzzle velocity will require the # scale factor to be increased significantly) self.scalefactor = 10 # Initialise the Turtle object Turtle.__init__(self, shape="circle") # Hide the turtle as soon as possible, otherwise you get ugly flashes at the centre of the screen self.hideturtle() # Give the cannonball its form self.penup() self.color("black") self.pencolor("red") self.resizemode("user") self.shapesize(8 / self.scalefactor) # Having y offset as zero pushes the start & end of a trajectory off the bottom of the screen, # so elevate it slightly (10 pixels seems to work) y_offset = 10 self.setposition(-window_width // 2, -window_height // 2 + y_offset) # All points will be plotted relative to this position self.starting_position = self.position() # Now make the cannonball visible self.showturtle() self.pendown()
def __init__(self): Turtle.__init__(self) self.shape("circle") self.penup() self.shapesize(stretch_len=0.5, stretch_wid=0.5) self.color("blue") self.speed("fastest")
def __init__ (self, size, color): Turtle.__init__(self) turtle.home() turtle.begin_poly() i = 6 turtle.pu()
def __init__(self, color1): Turtle.__init__(self) self.shape("square") self.color(color1) self.shapesize(0.5) self.penup() self.speed(0)
def __init__(self, color): Turtle.__init__(self) self.speed(0) self.color(color) self.penup() self.hideturtle() self.goto(0, 260)
def __init__(self, stype, level, width): Turtle.__init__(self) self.pu() self.goto(0, -screen_width + (level + 0.5) * width) self.isStreet = stype self.level = level self.width = width self.shape("square") self.shapesize(self.width / 10, screen_width, None) if self.isStreet == 1: self.color("dark slate grey") self.number_of_cars = random.randint(MINIMUM_CARS, MAXIMUM_CARS) else: self.color("green2") self.number_of_cars = 0 self.cars = [] for i in range(self.number_of_cars): rSPEED = random.randint(-15, 15) while (rSPEED > -10 and rSPEED <= 0) or (rSPEED < 10 and rSPEED >= 0): rSPEED = random.randint(-15, 15) rCOLOR = (random.random(), random.random(), random.random()) rPOS = (random.randint(-screen_width / 2, screen_width / 2), -screen_width + (level) * width) rWIDTH = random.randint(5, 10) car = Car(rSPEED, rCOLOR, rPOS, rWIDTH, self.level) self.cars.append(car) CARS.append(car) update()
def __init__(self, speed, depot, capacity, shape): Turtle.__init__(self, shape) self.speed = speed self.depot = depot self.capacity = capacity self.pencolor(random.random(), random.random(), random.random()) self.pensize(3)
def __init__(self, x, y, color): Turtle.__init__(self) self.penup() self.goto(x, y) self.shape("circle") self.color(color) self.shapesize(0.4)
def __init__(self, size): Turtle.__init__(self) self.shape(r()) r1 = random.randint(0, 255) g1 = random.randint(0, 255) b1 = random.randint(0, 255) self.color(r1, g1, b1)
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
def __init__(self, x): Turtle.__init__(self) turtle.register_shape("Hexagon", ((0, 0), (x, 0), (2 * x, x), (2 * x, x * 2), (x, 3 * x), (0, 3 * x), (-x, 2 * x), (-x, x), (0, 0))) self.shape("Hexagon")
def __init__(self, bilddatei, game): Turtle.__init__(self, bilddatei) self.game = game self.penup() self.speed(0) self.onclick(self.hit) self.start()
def __init__(self, name, coord, game_arena, kb): Turtle.__init__(self) self.speed(0) self.penup() if name is "p1": self.shape("tank_left") self.mult = 1 else: self.shape("tank_right") self.mult = -1 self.radians() self.seth(0) self.step_size = self.mult * PLAYER_SPEED self.turn_size = PLAYER_TURN_SPEED * pi / 180 self.fireTime = -1 self.health = PLAYER_HEALTH self.radius = 30 self.name = name self.setx(coord[0]) self.sety(coord[1]) self.kb = kb self.obstacles = game_arena.get_obstacles()
def __init__(self, name, coord, game_arena, kb): """Take in the parameters, Return initialize value of player""" Turtle.__init__(self) self.speed(0) self.penup() self.health = 0 if name is "p1": self.shape("tank_left") self.mult = 1 else: self.shape("tank_right") self.mult = -1 self.radians() self.seth(0) self.step_size = self.mult * PLAYER_SPEED self.turn_size = PLAYER_TURN_SPEED * pi / 180 self.fireTime = -1 if self.health == 0: def input_health(): window = turtle.Screen() health = turtle.textinput("Health", "Input main health:") return int(health) self.health = input_health() self.radius = 30 self.name = name self.setx(coord[0]) self.sety(coord[1]) self.kb = kb self.obstacles = game_arena.get_obstacles()
def __init__(self, distance, color, speed): Turtle.__init__(self) self.pencolor(color) self.speed = speed self.penup() self.forward(distance) self.pendown()
def __init__(self): Turtle.__init__(self) self._xmaxsize = 512 self._ymaxsize = 256 self.rightPaddlePosition = 0 self.leftPaddlePosition = 0 self.screen.setup(self._xmaxsize * 2, self._ymaxsize * 2) self.hideturtle() self.penup() self._x, self._y = 0, randint(-self._ymaxsize, self._ymaxsize) self.goto(self._x, self._y) self.shape("circle") self.shapesize(.1, .1, 5) self.speed(0) self._speed = 3 self._xdir, self._ydir = self._speed, self._speed self._xlimit, self._ylimit = self._xmaxsize, self._ymaxsize self.showturtle() self.screen.onkey(self.moveRightPaddleUp, "Up") self.screen.onkey(self.moveRightPaddleDown, "Down") self.screen.onkey(self.moveLeftPaddleUp, "q") self.screen.onkey(self.moveLeftPaddleDown, "a") self.screen.listen() self.rightPaddle = Paddle("R") self.leftPaddle = Paddle("L")
def __init__(self): Turtle.__init__(self, "circle") self.color("white") self.penup() self.x_move = 10 self.y_move = 10 self.move_speed = 0.1
def __init__(self, radius, dx, dy, color): Turtle.__init__(self) self.shape("circle") self.radius = radius self.dx = random.randint(20, 40) / 40 self.dy = random.randint(30, 50) / 40 self.shapesize(radius / 10) self.color(color)
def __init__(self, dx, dy): Turtle.__init__(self) turtle.register_shape('trump.gif') self.dx = dx self.dy = dy self.shape('trump.gif') self.pu() self.speed(0)
def __init__(self, radius, color, dx, dy): Turtle.__init__(self) self.radius = radius self.dx = dx self.dy = dy self.penup() self.shape("circle") self.color(color)
def __init__(self, x, y, step, shape, color): Turtle.__init__(self) self.penup() self.speed(0) self.goto(x, y) self.color(color) self.shape(shape) self.step = step
def __init__(self, x, y, radius, color): Turtle.__init__(self) self.pu() self.shape("circle") self.shapesize(radius / 10) self.radius = radius self.color(color) self.goto(x, y)
def __init__(self): Turtle.__init__(self) self.color("red") self.pensize(2) self.shape("turtle") self.speed(0) self.odometer = 0 self.flat_tyre = False
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)
def __init__ (self,x,y, color): Turtle.__init__(self) self.penup() self.shape("circle") self.shapesize(.5) self.radius =.5 self.color("black") self.goto(x, y)
def __init__ (self,x,y, color): Turtle.__init__(self) self.penup() self.shape("circle") self.shapesize(3) self.radius =3 self.color("green") self.goto(x, y)
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)
def __init__(self): Turtle.__init__(self) self.penup() self.color('green') self.shape('turtle') self.speed(1) self.nextX = 1 self.nextY = 0
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)
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)
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()
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()
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)
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)
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
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
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()
def __init__(self, x, y): Turtle.__init__(self) self.shape("turtle") self.resizemode("user") self.shapesize(3,3,5) self.pensize(10) self._color = [0,0,0] self.x = x self._color[x] = y self.color(self._color) self.speed(0) self.left(90) self.pu() self.goto(x,0) self.pd() self.sety(1) self.pu() self.sety(y) self.pencolor("gray25") self.ondrag(self.shift)
def __init__(self, col, row): Turtle.__init__(self, shape="square", visible=False) self.pu() self.goto(coords(col, row)) self.color("black") self.shapesize((SQUARE_WIDTH-2)/20.0)
def __init__(self): Turtle.__init__(self)
def __init__(self): Turtle.__init__(self) self.up() self.setpos(random.randrange(-500, 500), random.randrange(-500, 500)) self.shape("circle") Obstacle.obstacles.append(self)
def __init__(self, n, x, y): Turtle.__init__(self, visible=False) self.n = n self.speed(0) self.penup() self.goto(x, y)
def __init__(self): Turtle.__init__(self) self.up() self.setpos(random.randrange(-200,200),random.randrange(-200,200)) self.shape('circle') Obstacles.obstacle.append(self)
def __init__(self, bilddatei, game): Turtle.__init__(self, bilddatei) # self.game = game self.penup() self.speed(0) self.goto(0,0)
def __init__(self): Turtle.__init__(self) self.speed(0) self.hideturtle() self.tstack = []
def __init__(self, w, h): Turtle.__init__(self, visible=False) self.screen = Screen() self.screen.setup(w, h) self.speed(0) self.penup() self.goto(-WINWIDTH//2 + 50, -WINHEIGHT//2 + 20) self.pencolor("yellow")