Ejemplo n.º 1
0
    def test_pygame2_base_Rect_collidepoint(self):

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

        # Rect.collidepoint (x, y) -> bool
        # 
        # Test if a point is inside a rectangle.
        # 
        # Returns true if the given point is inside the rectangle.  A
        # point along the right or bottom edge is not considered to be
        # inside the rectangle.
        r = Rect( 1, 2, 3, 4 )
        
        self.assertTrue( r.collidepoint( r.left, r.top ),
                         "r does not collide with point (left,top)" )
        self.assertFalse( r.collidepoint( r.left-1, r.top ),
                     "r collides with point (left-1,top)"  )
        self.assertFalse( r.collidepoint( r.left, r.top-1 ),
                     "r collides with point (left,top-1)"  )
        self.assertFalse( r.collidepoint( r.left-1,r.top-1 ),
                     "r collides with point (left-1,top-1)"  )
        
        self.assertTrue( r.collidepoint( r.right-1, r.bottom-1 ),
                         "r does not collide with point (right-1,bottom-1)")
        self.assertFalse( r.collidepoint( r.right, r.bottom ),
                     "r collides with point (right,bottom)" )
        self.assertFalse( r.collidepoint( r.right-1, r.bottom ),
                     "r collides with point (right-1,bottom)" )
        self.assertFalse( r.collidepoint( r.right, r.bottom-1 ),
                     "r collides with point (right,bottom-1)" )