Game Stuff Programming
Game Stuff Programming
// Questions
TriviaData[0][0] = "A preposition is usually followed by a "noun".";
TriviaData[1][0] = "Phrasal verbs always consist of two words.";
TriviaData[2][0] = "The past tense of "must" is "musted";
TriviaData[3][0] = "The verb "to think" is never used in continuous
tenses.";
TriviaData[4][0] = "Questions always use an auxiliary verb.";
TriviaData[5][0] = ""Used to doing" and "used to do" mean approximately the
same thing.";
TriviaData[6][0] = "The word "people" is always uncountable.";
TriviaData[7][0] = "The shortest possible sentence contains a subject, a
verb and an object.";
TriviaData[8][0] = "The main verb and the direct object are not normally
separated.";
TriviaData[9][0] = "The auxiliary verb "to do" is never used in the present
simple affirmative.";
// Answers
TriviaData[0][1] = "true";
TriviaData[1][1] = "false";
TriviaData[2][1] = "false";
TriviaData[3][1] = "false";
TriviaData[4][1] = "false";
TriviaData[5][1] = "false";
TriviaData[6][1] = "false";
TriviaData[7][1] = "false";
TriviaData[8][1] = "true";
TriviaData[9][1] = "false";
// Sets question text and indicator so that we know the question has been
displayed
function setQuestion() {
selectionValid = false; // Flag to make sure question has not been asked
yet
while (selectionValid == false) {
currentQuestion = Math.floor(Math.random() * 10); // randomly select
starting question
if (TriviaData[currentQuestion][2] == "no") {
selectionValid = true;
}
}
document.getElementById("TriviaQuestion").innerHTML =
TriviaData[currentQuestion][0];
TriviaData[currentQuestion][2] = "yes";
questionsAsked = questionsAsked + 1;
}
function processAnswer(myAnswer) {
if (TriviaData[currentQuestion][1] == myAnswer) {
// answer correct
totalCorrect = totalCorrect + 1;
}
}
</script>