class ImageHandler(PhysObject): """ Sprite with GObject image in class attributes for RAM economy """ size_inc = 1 _frames = [] IMAGE_SHIFT = Vec2d(0, 0) def __init__(self, *args, obj=None, **kwargs): super().__init__(*args, **kwargs) if obj is None: self._image = GObject(self._frames) else: self._image = GObject(obj) def end_step(self): super().end_step() self._image.update(self.step_time) @classmethod def image_to_local(cls, pos): return Vec2d(pos) * cls.size_inc + cls.IMAGE_SHIFT def _get_image(self): return self._image.read()
class StaticImage(BaseSprite): draw_layer = DRAW_LAYER.VFX size_inc = 1 _frames = [] IMAGE_SHIFT = Vec2d(0, 0) def __init__(self, *args, obj=None, **kwargs): super().__init__(*args, **kwargs) if obj is None: self._image = GObject(self._frames) else: self._image = GObject(obj) def end_step(self): super().end_step() self._image.update(self.step_time) @classmethod def image_to_local(cls, pos): return Vec2d(pos) * cls.size_inc + cls.IMAGE_SHIFT def _get_image(self): return self._image.read()