def bump_to(self, target, callback): path = [] x, y = target self.update_orientation(x, y) start = self.pos end = (start[0] + x) / 2, (start[1] + y) / 2 path.extend(tween.tween(start, end, int(0.1 * FPS))) path.extend(tween.tween(end, start, int(0.1 * FPS))) self._action = self.do_move self._callback = callback self._path = path
def __init__(self, start, end, frames): x, y = start direction = 0, 0 while direction == (0, 0): direction = random.randint(-10, 10), random.randint(-10, 10) direction = normalize(direction) distance = random.randint(10, 30) / 10 dx, dy = map((lambda x: x * distance), direction) climax = (x + dx, y + dy) self._path = list( tween.tween(start, climax, frames // 2, tween.EASE_OUT_QUAD)) self._path += list( tween.tween(climax, end, frames // 2, tween.EASE_IN_QUAD)) self.color = self.get_color()
def __init__(self, center): self._center = center r = random.randint(0, 10) / 100 t = random.choice( [r, math.pi / 2 + r, math.pi + r, math.pi * 3 / 2 + r]) # t = random.choice([r, math.pi + r]) self._path = list(tween.tween((2 + r, 2 * math.pi + t), (r, t), 20)) self._color = random.choice([8, 14])
def __init__(self, pos): x, y = pos direction = 0, 0 while direction == (0, 0): direction = random.randint(-10, 10), random.randint(-10, 10) direction = normalize(direction) distance = random.randint(5, 20) / 10 dx, dy = map((lambda x: x * distance), direction) self._path = list( tween.tween(pos, (x + dx, y + dy), 20, tween.EASE_IN_QUAD)) self.color = random.choice([6, 7, 12])
def rwalk(a, b): d = int(dist(a, b) / CELL_SIZE) + 2 path = list(tween.tween(a, b, d)) def _distort(p): x, y = p delta = random.gauss(0, CELL_SIZE / 3) nx, ny = normalize((y, -x)) dx = nx * delta dy = ny * delta return x + dx, y + dy return [_distort(p) for p in path[:-1]] + [path[-1]]
def __init__(self, start, end, callback=None): speed = 1 / 15 d = dist(start, end) self._path = list(tween.tween(start, end, int(speed * d * FPS))) self._callback = callback
def __init__(self, text, pos, color): self.text = text self.color = color x, y = pos self._path = list( tween.tween(pos, (x, y - 10), 45, tween.EASE_OUT_QUAD))
def move(self, x, y, callback, frames=int(FPS * 0.3)): self.update_orientation(x, y) self._action = self.do_move self._callback = callback self._path = list(tween.tween(self.pos, (x, y), frames))