Skip to content

Commit

Permalink
Added return to notebook button
Browse files Browse the repository at this point in the history
  • Loading branch information
LukePng committed Aug 16, 2024
1 parent 3c87d78 commit e42fda5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
12 changes: 4 additions & 8 deletions src/game/game.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
let score = 0;
let combo = 0;
let currentQuestionIndex = 0;
let timeLeft = 60; // 60 seconds for the quiz
let timeLeft = 60;
let timer;
let questions;
let timeout;
let wrongQuestions = []; // Track wrong questions
let wrongQuestions = []
let maxCombo = 0;
let wrongQuestionIndex = 0;

const bgmElement = document.getElementById('bgm');
const bgmEndElement = document.getElementById('bgm_end');
Expand Down Expand Up @@ -74,7 +75,6 @@ function generateRandomQuestions(numQuestions) {
return questions;
}


function loadQuestion() {
const questionElement = document.getElementById('question');
const optionsElements = document.querySelectorAll('.option');
Expand Down Expand Up @@ -147,7 +147,6 @@ function checkAnswer(selectedOptionIndex) {
options.forEach(option => option.disabled = true);
}


function updateProgressBar() {
const progressBar = document.getElementById('progress-bar');
const star1 = document.getElementById('star1');
Expand Down Expand Up @@ -179,7 +178,6 @@ function updateProgressBar() {
}
}


function nextQuestion() {
clearTimeout(timeout);
currentQuestionIndex += 1;
Expand Down Expand Up @@ -242,6 +240,7 @@ function endQuiz() {

// Show restart button at the end
document.getElementById('restart-button').classList.remove('hidden');
document.getElementById('return-button').classList.remove('hidden');

if (wrongQuestions.length > 0) {
document.getElementById('wrong-questions-container').classList.remove('hidden');
Expand All @@ -259,9 +258,6 @@ function endQuiz() {
bgmEndElement.play();
}


let wrongQuestionIndex = 0;

function showWrongQuestion(index) {
const wrongQuestion = wrongQuestions[index];
document.getElementById('wrong-question-number').textContent = `Question ${wrongQuestion.questionNumber}`;
Expand Down
3 changes: 2 additions & 1 deletion src/game/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ body {
#prev-wrong-button,
#next-wrong-button,
#next-button,
#restart-button {
#restart-button,
#return-button {
padding: 10px 20px;
margin: 5px;
font-size: 16px;
Expand Down
8 changes: 6 additions & 2 deletions src/game/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,14 @@ <h3>Wrong Answers Review</h3>
</div>

<p id="explanation" class="hidden"></p>

<button id="next-button" class="hidden" onclick="nextQuestion()">Next Question</button>
<button id="restart-button" class="hidden" onclick="restartQuiz()">Restart Quiz</button>

<div>
<button id="restart-button" class="hidden" onclick="restartQuiz()">Restart Quiz</button>
<a href="https://thetrustypwo.github.io/Superposition/">
<button id="return-button" class="hidden">Return to Notebook</button>
</a>
</div>

</div>
<audio id="bgm" src="assets/audio/bgm.mpeg" autoplay loop></audio>
Expand Down

0 comments on commit e42fda5

Please sign in to comment.