Exemplo n.º 1
0
    def test_pygame2_base_Rect_collidedictall(self):

        # __doc__ (as of 2008-10-17) for pygame2.base.Rect.collidedictall:

        # Rect.collidedictall (dict) -> [(key, value), ...]
        # 
        # Test if all rectangles in a dictionary intersect.
        # 
        # Returns a list of all the key and value pairs that intersect
        # with the Rect. If no collisions are found an empty list is
        # returned. They keys of the passed dict must be Rect objects.

        r = Rect(1, 1, 10, 10)

        r2 = Rect(1, 1, 10, 10)
        r3 = Rect(5, 5, 10, 10)
        r4 = Rect(10, 10, 10, 10)
        r5 = Rect(50, 50, 10, 10)

        rects_values = 1
        d = {2: r2}
        l = r.collidedictall(d, rects_values)
        self.assertEqual(l, [(2, r2)])

        d2 = {2: r2, 3: r3, 4: r4, 5: r5}
        l2 = r.collidedictall(d2, rects_values)
        self.assertEqual(l2, [(2, r2), (3, r3), (4, r4)])