Example #1
0
    def test_convert(self):
        self.assertIsInstance(Vector2D.convert((1, 2)), Vector2D)
        self.assertIsInstance(Vector2D.convert([1, 2]), Vector2D)
        self.assertIs(Vector2D.convert(self.vector), self.vector)

        self.assertRaises(TypeError, Vector2D.convert, (1, 2, 3))
        self.assertRaises(TypeError, Vector2D.convert, [1, 2, 3])
Example #2
0
    def __init__(self, position, image=None, image_mask=None, layers=None,
                 is_enabled=True, is_visible=True):
        """

        :param image: An image to use as object visualization
        :param image_mask: Defines which pixels of image to use when object
        is checked for intersection
        :type position: pygvent.vector2d.Vector2D|list|tuple
        :type is_visible: bool
        """
        super(VisibleGameObject, self).__init__(layers, is_enabled)
        self.image = image
        self.mask = image_mask

        self._is_visible = is_visible
        self._position = Vector2D.convert(position)