def test_is_false_for_line_in_the_bottom_left_corner(self):
        corner = Point(
            self.obstacle.rect.left,
            self.obstacle.rect.bottom)
        
        # Build a line so that the player is on its edge
        line = Polygon([
            corner + Point(-10, -10),
            corner + Point(10, 10)])

        self.assertFalse(
            self.obstacle.is_to_the_right(line))
Example #2
0
 def test_creates_a_polygon(self):
     self.assertEqual(rectangle(A, E), Polygon([A, B, E, D]))
Example #3
0
 def test_distance_y_positive(self):
     first = Polygon([A, B])
     other = Polygon([C, E, D])
     self.assertEqual(first.distance_y(other), 2)
Example #4
0
 def test_distance_x_negative(self):
     first = Polygon([B, E])
     other = Polygon([A, C, D])
     self.assertEqual(first.distance_x(other), -2)
Example #5
0
 def test_distance_x_positive(self):
     first = Polygon([A, D])
     other = Polygon([B, C, E])
     self.assertEqual(first.distance_x(other), 2)
Example #6
0
 def test_build_surface_mask(self):
     polygon = Polygon([A, B, C])
     expected = np.array([[1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 0, 0],
                          [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0],
                          [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]])
     self.assertTrue(np.array_equal(polygon.build_surface_mask(), expected))
Example #7
0
 def test_edges(self):
     polygon = Polygon([A, B, C])
     expected = [Edge(A, B), Edge(B, C), Edge(C, A)]
     self.assertEqual(polygon.edges(), expected)
Example #8
0
 def test_radius(self):
     polygon = Polygon([A, B, E, D])
     self.assertEqual(polygon.radius(), ceil(2 * sqrt(2)))
Example #9
0
 def test_centre(self):
     polygon = Polygon([A, B, E, D])
     self.assertEqual(polygon.centre(), C)