Ejemplo n.º 1
0
 def GetHidingPosition(self, hunter, obj):
     # set the distance between the object and the hiding point
     DistFromBoundary = 30.0  # system setting
     DistAway = obj.radius + DistFromBoundary
     # get the normal vector from the hunter to the hiding point
     ToObj = Vector2D.get_normalised(obj.pos - hunter.pos)
     # scale size past the object to the hiding location
     return (ToObj * DistAway) + obj.pos
Ejemplo n.º 2
0
    def hide(self, hunter_pos, delta):
        if self.world.hunter is self:
            return self.wander(delta)

        best_hiding_spot = None
        best_hiding_dist = 99999999999

        for obs in self.world.obstacles:
            boundary_dist = obs.radius + (obs.radius/2)
            hiding_spot = obs.pos + Vector2D.get_normalised(obs.pos - hunter_pos) * boundary_dist
            hiding_dist = Vector2D.distance(self.pos, hiding_spot)**2

            if hiding_dist < best_hiding_dist:
                best_hiding_spot = hiding_spot
                best_hiding_dist = hiding_dist
            egi.green_pen()
            egi.cross(hiding_spot,10)

        return self.arrive(best_hiding_spot, "fast")