See more:
(untagged)
I am trying to do a game where there is a map with levels and on each level there is a question, if you answer the question correctly the button will change its color to green else red. But I don't know how to make the code do the same but with different answers.
This are the questions and answers:
1.Who wrote one of his sonatas entirely at night and so called it the "Moonlight Sonata"? (Beethoven)
2.He was fond of incorporating the numbers 14 and 41 into his musical works, because they were derived from the mystical numerology values of the letters in his own name? (Bach)
3. He wrote his first opera, Mitridate Re di Ponto, in 1770 when he was only 14 years old? (Mozart)
4. His music is known for its humor? (Haydn)
Choose and type your answer:
A - Sebastian Bach
B - Joseph Haydn
C - Beethoven
D - Amadeus Mozart
What I have tried:
//Map game
function Game_Question() {
var choice = prompt("Enter a Choice");
getText("Answer_text1");
if (choice == "C") {
setProperty("button_Qlevel1", "background-color", "green");
} else {
setProperty("button_Qlevel1", "background-color", "red");
}
if (choice == "A") {
setProperty("button_Qlevel2", "background-color", "green");
} else {
setProperty("button_Qlevel2", "background-color", "red");
}
if (choice == "D") {
setProperty("button_Qlevel3", "background-color", "green");
} else {
setProperty("button_Qlevel3", "background-color", "red");
}
if (choice == "B") {
setProperty("button_Qlevel4", "background-color", "green");
} else {
setProperty("button_Qlevel4", "background-color", "red");
}
setScreen("GameMapscreen");