コード例 #1
0
ファイル: core.py プロジェクト: hpointu/rogueweek
    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
コード例 #2
0
 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()
コード例 #3
0
 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])
コード例 #4
0
 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])
コード例 #5
0
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]]
コード例 #6
0
 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
コード例 #7
0
 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))
コード例 #8
0
ファイル: core.py プロジェクト: hpointu/rogueweek
 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))