Ejemplo n.º 1
0
def setup(world):
    '''This stress-tests the dynamic tree broad-phase.

    It also shows that tile based collision is _not_ smooth due to Box2D not
    knowing about adjacency.
    '''

    a = 0.5

    def ground_positions():
        N = 200
        M = 10
        position = Vec2(0, 0)
        for i in range(M):
            position.x = -N * a
            for j in range(N):
                yield position
                position.x += 2.0 * a
            position.y -= 2.0 * a

    ground = world.create_static_body(position=(0, -a))

    for position in ground_positions():
        ground.create_polygon_fixture(box=(a, a, position, 0))

    create_pyramid(world)
Ejemplo n.º 2
0
 def test_valid_5_reversed_true(self):
     res = pyramid.create_pyramid(5, "reversed", True)
     self.assertIsInstance(res, list)
     self.assertEqual(res, [
         "* * * * * ", " * * * *  ", "  * * *   ", "   * *    ",
         "    *     "
     ])
Ejemplo n.º 3
0
 def test_valid_5_normal_true(self):
     res = pyramid.create_pyramid(5, "normal", True)
     self.assertIsInstance(res, list)
     self.assertEqual(res, [
         "    *     ", "   * *    ", "  * * *   ", " * * * *  ",
         "* * * * * "
     ])
Ejemplo n.º 4
0
 def test_valid_0_reversed_true(self):
     res = pyramid.create_pyramid(0, "reversed", True)
     self.assertIsInstance(res, list)
     self.assertEqual(res, [])