Exemplo n.º 1
0
 def testNull(self):
     """Properties for null vector"""
     self.assertTrue(NULL_VECTOR.is_null())
     self.assertTrue(Vec2d(0, 0).is_null())
     self.assertTrue(Vec2d.origin_to(Point(0,0)).is_null())
     a_pt = Point(1,2)
     self.assertTrue(Vec2d.from_to(a_pt, a_pt).is_null())
Exemplo n.º 2
0
    def arrive(self, target: Point, deceleration=FAST) -> Vec2d:
        """Similar a seek pero llegando con velocidad nula."""

        to_target = Vec2d.origin_to(target - self.player.pos)
        # distance to target
        dist = to_target.get_length()

        if dist > 25:
            # Para ajustar la deceleración...
            decelerationTweaker = 3
            # Cálculo de la velocidad requerida.
            speed = min(dist / (deceleration * decelerationTweaker), self.player.max_speed.get_length())
            # velocity:
            desired_velocity = to_target * speed / dist # Vec2d(to_target * speed / dist)

            ## FIX THIS TYPE :::

            return desired_velocity - self.player.velocity
        else:
            return Vec2d(0, 0)