Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self._image = GObject(self._frames)
     self._image.fps = 10
     self._image.que_end(self.kill)
     size = self._image.get_size()
     a = (size[0] * size[0] + size[1] * size[1]) ** .5
     self.size = (a, a)
Ejemplo n.º 3
0
class VideoEffect(StaticImage):
    size_inc = .6

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._image = GObject(self._frames)
        self._image.fps = 10
        self._image.que_end(self.kill)
        size = self._image.get_size()
        a = (size[0] * size[0] + size[1] * size[1]) ** .5
        self.size = (a, a)

    @classmethod
    def init_class(cls):
        cls._frames, cls.IMAGE_SHIFT = cast_model(MODEL, CS, cls.size_inc)
Ejemplo n.º 4
0
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()
Ejemplo n.º 5
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)