Skip to content

Huset når ikke at tegne færdigt, det kan løses med et par betingelser #2

@simmoe

Description

@simmoe

function draw() {
if (direction == "left") pen.x -= 1;
if (direction == "right") pen.x += 1;
if (direction == "up") pen.y -= 1;
if (direction == "down") pen.y += 1;
if (direction == "hus") {
if (!houseDrawing) {
houseDrawing = true;
timer = millis();
}
let time = millis() - timer;

    if (time < 3000) {
        pen.x--;
    }
    if (time < 4500 && time > 3000) {
        pen.y--;
    }
    if (time < 6000 && time > 4500) {
        pen.y--;
        pen.x++;
    }
    if (time < 7500 && time > 6000) {
        pen.y++;
        pen.x++;
    }
    if (time < 9000 && time > 7500) {
        pen.y++;
    }
    if (time > 9000) {
        houseDrawing = false;
        direction = "";
    }
}
pen.show();
pen.bounce();

}

function showResult() {
if (!houseDrawing) {
if (myRec.resultValue == true) {
word = myRec.resultString.split(' ').pop();
switch (word.toLowerCase()) {
case 'left':
case 'let':
case 'depth':
direction = "left"
break;
case 'right':
direction = "right"
break;
case 'up':
case 'op':
direction = "up"
break;
case 'down':
direction = "down"
break;
case 'hus':
direction = "hus"
break;
default:
direction = "stop"
}
}
}else{
word = "Drawing a house, please wait..."
}
displayWord.html(word.toLowerCase());
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions