class Drunk(VMobject): CONFIG = { "direction": RIGHT, "color": YELLOW_E, "height": 1, } def generate_points(self): self.drunk = SVGMobject(file_name="drunk", color=self.color, height=self.height) self.point = VectorizedPoint(self.drunk.get_bottom()) self.add(self.drunk, self.point) self.rotate(angle_between(RIGHT, self.direction)) def get_position(self): return self.point.get_center() def step_on(self, position): self.shift(position - self.get_position()) return self def turn_around(self, **kwargs): axis = rotate_vector(self.direction, np.pi / 2) self.rotate(np.pi, axis=axis, **kwargs) self.change_direction() return self def get_direction(self): return self.direction def change_direction(self): self.direction = -self.direction
class House(VMobject): CONFIG = { "color": DARK_GREY, "height": 3, } def generate_points(self): self.house = SVGMobject(file_name="house", color=self.color, height=self.height) self.point = VectorizedPoint(self.house.get_bottom()) self.add(self.house, self.point) def get_position(self): return self.point.get_center() def place_on(self, position): self.shift(position - self.get_position()) return self