mercredi 14 octobre 2020

Khan Academy: If Statements 2

My if statement is not working, like last time but this time the line won't x = x - 1; in my if statement (I didn't do the else if because I thought it's the problem). Link: https://www.khanacademy.org/computer-programming/probability/5609184564559872. Code:

var x = 78;
var y = 18;

// Just in case I test
var saveX = 78;
var saveY = 18;

draw = function() {
    background(150, 255, 250);
    
    strokeWeight(1);
    stroke(0, 0, 0);
    rect(78, 20, 254, 25);
    
    strokeWeight(6);
    stroke(255, 0, 0);
    line(x, y, x, y + 29);
    
    
    if (x > 332) {
        x = x - 2;
    }
    
    if (x < 78) {
        x = x + 2;
    }
    
    x = x + 2;
};

Aucun commentaire:

Enregistrer un commentaire