mercredi 27 septembre 2017

If an if statement gets called and all the conditions are true, do all the else if statements get called also?

If an if statement gets called and all the conditions are true, do all the else if statements get called also?

like:

if coins > 19 && speedLvl == 1 {
    speedLvl = 2
    coins = coins - 20
}

else if coins > 49 && speedLvl == 2 {
    speedLvl = 3
    coins = coins - 50
            }

else if coins > 99 && speedLvl == 3 {
    speedLvl = 4
    coins = coins - 100
}

If the player has 1000 coins do then speedLvl the go to 4 ?

Aucun commentaire:

Enregistrer un commentaire