Esempio n. 1
0
 def test_a_single_block_moves_one_iteration_successfully(self):
     platform = Platformer(positions=[(2, 1)], directions=[(-1, 0)])
     platform.move_blocks()
     self.assertEqual(1, len(platform.get_block_positions()))
     self.assertTrue(platform.block_position_exists((1, 1)))
     self.assertListEqual([(1, 1)], platform.get_block_positions())
     self.assertListEqual([(-1, 0)], platform.get_block_directions())
Esempio n. 2
0
 def test_platform_with_custom_positions(self):
     result = Platformer(number_blocks=10, positions=[(2, 3), (3, 4)])
     self.assertEqual(2, len(result.get_block_positions()))
     self.assertTrue(result.block_position_exists((2, 3)))
     self.assertListEqual([(2, 3), (3, 4)], result.get_block_positions())
     self.assertEqual(len(result.get_block_positions()),
                      len(result.get_block_directions()))
Esempio n. 3
0
 def test_basic_custom_platform(self):
     result = Platformer(number_blocks=10)
     self.assertEqual(10, len(result.get_block_positions()))
     self.assertEqual(len(result.get_block_positions()),
                      len(list(set(result.get_block_positions()))))
     self.assertEqual(len(result.get_block_positions()),
                      len(result.get_block_directions()))
Esempio n. 4
0
 def test_two_blocks_move_one_iteration_successfully(self):
     platform = Platformer(positions=[(2, 1), (3, 2)],
                           directions=[(-1, 0), (0, 1)])
     platform.move_blocks()
     self.assertEqual(2, len(platform.get_block_positions()))
     self.assertTrue(platform.block_position_exists((1, 1)))
     self.assertTrue(platform.block_position_exists((3, 3)))
     self.assertListEqual([(1, 1), (3, 3)], platform.get_block_positions())
     self.assertListEqual([(-1, 0), (0, 1)],
                          platform.get_block_directions())
Esempio n. 5
0
def the_platform(xz=None):
    block_id = block.WOOD_PLANKS.id
    plane = Plane(x=xz[0], z=xz[1])
    platform = Platformer(number_blocks=NUMBER_BLOCKS, block_size=PLATFORM_BLOCK_SIZE, plane=plane)

    #create the platform shapes
    platform_shapes = []
    for pos in platform.get_block_positions():
        block_pos = Vec3(pos[0], arenaPos.y, pos[1])
        platform_blocks = []
        for x in range(PLATFORM_BLOCK_SIZE):
            for z in range(PLATFORM_BLOCK_SIZE):
                platform_blocks.append(minecraftstuff.ShapeBlock(x, 0, z, block_id))
        platform_shape = minecraftstuff.MinecraftShape(mc, block_pos, platform_blocks)
        platform_shapes.append(platform_shape)

    #move the platforms
    while not levelComplete:
        platform.move_blocks()
        directions = platform.get_block_directions()
        for i in range(len(directions)):
            platform_shapes[i].moveBy(directions[i][0], 0, directions[i][1])
            time.sleep(PLATFORM_SLEEP_TIME)
Esempio n. 6
0
 def test_default_platform(self):
     result = Platformer()
     self.assertEqual(len(result.get_block_positions()),
                      len(list(set(result.get_block_positions()))))
     self.assertEqual(len(result.get_block_positions()),
                      len(result.get_block_directions()))