9-9 村の自慢③

解説動画

解答コード

function floor2(depth: number, width: number, typeOfBlock: number) {
    for (let i = 0; i < width; i++) {
        for(let j = 0; j < depth; j++) {
            agent.setItem(typeOfBlock, 64, 1);
            agent.move(FORWARD, 1);
            agent.place(DOWN);
        }
        agent.move(BACK, depth);
        agent.move(RIGHT, 1);
    }
}

function roof2(depth: number, width: number, steps: number) {
    agent.move(UP, 1);
    for (let k = 0; k < steps; k++) {
        floor2(depth, width);
        agent.move(UP, 1);
        agent.move(LEFT, width - 1);
        agent.move(FORWARD, 1);
        depth -= 2;
        width -= 2;
    }
}

player.onChat("9-9", function (depth, width, steps) {
    roof2(depth, width, steps);
});