Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
867 B
67
Indexable
Never
//This Program Has Karel make three ball height towers infinitely

function start() {
    buildTower1();
    descendTower();
    loopTowers();

}

//This makes loop of building towers
function loopTowers(){
    while(noBallsPresent()){
        if(frontIsClear()){
            move();
            buildTower1();
            descendTower();
        }    

    }
}

//Karel Builds Tower of Three Balls
function buildTower1(){
    putBall();
    turnLeft();
    move();
    putBall();
    move();
    putBall();
}

//This Makes Karel Go Down To Street One
function descendTower(){
    if(rightIsClear()){
        turnRight();
        move();
        turnRight();
        move();
        move();
        turnLeft();

    }else{
        turnAround();
        move();
        move();
        turnLeft();
    }
}