class Shaped(Entity):
    """Shaped objects are things that occupy space."""
    
    @property
    def shape(self):
        #if isinstance(self, Movable):   
            #self._update_shape()
        return self._shape
        
    def position_update(self):
        self._update_shape()
        super().position_update()
        
    def _update_shape(self):
        if game.game_time != self._shape_time:
            self._shape.offset(Position(Vector(0, 0), self.velocity, self.acceleration, (game.game_time - self._shape_time) / 1000))
            self._shape_time = game.game_time

    def __init__(self, shape, enclosed=True, **kwargs):
        if isinstance(shape, Shape):
            self._shape = shape
        else:
            self._shape = Shape(shape, enclosed)
        if 'position' in kwargs:
            self._shape.offset(kwargs['position'])
            self._shape_time = game.game_time
        super().__init__(**kwargs)
 def __init__(self, shape, enclosed=True, **kwargs):
     if isinstance(shape, Shape):
         self._shape = shape
     else:
         self._shape = Shape(shape, enclosed)
     if 'position' in kwargs:
         self._shape.offset(kwargs['position'])
         self._shape_time = game.game_time
     super().__init__(**kwargs)
Exemple #3
0
    return r * np.sin(theta) + c


fig, axs = plt.subplots(3, 4)
axs = axs.reshape(3 * 4)
for ax in axs:
    ax.tick_params(bottom=False,
                   left=False,
                   labelbottom=False,
                   labelleft=False)
    ax.set_aspect(1)
    ax.set_xmargin(0.05)
    ax.set_ymargin(0.05)

#comma
comma = Shape()
comma.add_array(arc([0, -1], [1, 0], 1, major=True))
comma.add_array(arc([1, 0], [-1, -2], 2))
comma.add_array(arc([-1, -2], [0, -1], 1.5, out=False))
comma.rotate(20, update=True)

#circle
thetas = np.linspace(0, 2 * np.pi, 200)
circle = Shape()
circle.add_line(np.cos, np.sin, thetas)
circle.loop()

#1, 1
ax = axs[0]
circle.scale(11, 11).fill(ax, facecolor='black')
circle.scale(10, 10).fill(ax, facecolor='red')