def create_block(world: World, block_id: str, x: int, y: int, *args): """Create a new block instance and add it to the world based on the block_id. Parameters: world (World): The world where the block should be added to. block_id (str): The block identifier of the block to create. x (int): The x coordinate of the block. y (int): The y coordinate of the block. """ block_id = BLOCKS[block_id] if block_id == "mystery_empty": block = MysteryBlock() elif block_id == "mystery_coin": block = MysteryBlock(drop="coin", drop_range=(3, 6)) elif block_id == "bounce_block": # Adding bounce, tunnel and flag to the game world block = BounceBlock() elif block_id == "flag": block = FlagpoleBlock() elif block_id == "tunnel": block = TunnelBlock() elif block_id == "switch" : block = switch() else: block = Block(block_id) world.add_block(block, x * BLOCK_SIZE, y * BLOCK_SIZE)
def blocks_recover(self, brick_list, world: World): """Recover the hidden bricks Parameters: brick_list (list): store the bricks to be recovered and their coordinate looks like this : [(brick_object, x, y),] """ for n in brick_list: brick, x, y = n world.add_block(brick, x, y)