I'm trying to build the simplest text adventure possible by looping if statements with my startGame() function. How can I make it work? or am I barking up the wrong tree?
let m = 1;
function startGame() {
if (m === 1){
document.querySelector("#text").innerHTML = "START PAGE";
document.querySelector("#btn").value = 'Go to map 2';
document.querySelector("#btn").addEventListener("click", map2);
function map2() {
m = 2;
}
} else if (m === 2) {
document.querySelector("#text").innerHTML = "SUCCESS!!!";
} else {
document.querySelector("#text").innerHTML = "Nothing works";
}
}
startGame()
Aucun commentaire:
Enregistrer un commentaire