Skip to content

Commit

Permalink
resolving issue#20
Browse files Browse the repository at this point in the history
  • Loading branch information
Garima-149 committed Jan 10, 2024
1 parent bf58991 commit 60301d7
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 150 deletions.
7 changes: 7 additions & 0 deletions Dark/game.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@
margin-bottom:2px;
display:block;
}
#display{
border:2px solid black;
border-radius: 5px;
width:100%;
margin-bottom:2px;
display:block;
}
/* LOADER */
#loader {
border: 1.6rem solid white;
Expand Down
3 changes: 2 additions & 1 deletion Dark/game.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h1 class="hud-main-text" id="score">
</h1>
</div>
</div>
<h2 id="question"></h2>
<h2 id="question1">Question </h2><h2 id="question"></h2>
<div class="choice-container">
<p class="choice-prefix">A</p>
<p class="choice-text" data-number="1"></p>
Expand All @@ -54,6 +54,7 @@ <h2 id="question"></h2>
<p class="choice-prefix">D</p>
<p class="choice-text" data-number="4"></p>
</div>
<h2 id="display">Correct option :</h2>
<footer>
<button class="next_btn">Next Ques</button>
</footer>
Expand Down
26 changes: 25 additions & 1 deletion Dark/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const game = document.getElementById('game');
const time_line = document.querySelector(".time .time_line");
const timeText = document.querySelector(".timer .time_left_txt");
const timeCount = document.querySelector(".timer .timer_sec");

const question1= document.getElementById('question1');

var soundCorrect = new Audio("sounds/correctAns.mp3");
var soundIncorrect = new Audio("sounds/wrongAns.mp3");
Expand Down Expand Up @@ -84,6 +84,7 @@ getNewQuestion = () => {
return window.location.assign('end.html');
}
questionCounter++;
question1.innerText = `Question ${questionCounter}`;//update question number
progressText.innerText = `Question ${questionCounter}/${MAX_QUESTIONS}`;
//Update the progress bar
progressBarFull.style.width = `${(questionCounter / MAX_QUESTIONS) * 100}%`;
Expand Down Expand Up @@ -129,7 +130,10 @@ choices.forEach((choice) => {
soundCorrect.play();
} else {
soundIncorrect.play();
display(currentQuestion.answer);
}
setInterval(displaynone,4000);


selectedChoice.parentElement.classList.add(classToApply);
setTimeout(() => {
Expand Down Expand Up @@ -178,7 +182,27 @@ function startTimerLine(time) {
}
}
}
let string;
function display(string) {
let display = document.getElementById('display');
if (string == 1) {
display.innerText = `Correct option : A`;
}
if (string == 2) {
display.innerText = `Correct option : B`;
}
if (string == 3) {
display.innerText = `Correct option : C`;
}
if (string == 4) {
display.innerText = `Correct option : D`;
}

}
function displaynone() {
let display = document.getElementById('display');
display.innerText = `Correct option : `;
}
incrementScore = (num) => {
score += num;
scoreText.innerText = score;
Expand Down
8 changes: 7 additions & 1 deletion Light/game.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@
background-color: #56a5eb;
width: 0%;
}

#display{
border:2px solid black;
border-radius: 5px;
width:100%;
margin-bottom:2px;
display:block;
}
/* LOADER */
#loader {
border: 1.6rem solid white;
Expand Down
2 changes: 1 addition & 1 deletion Light/game.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h1 class="hud-main-text" id="score">
</h1>
</div>
</div>
<h2 id="question"></h2>
<h2 id="question1">Question </h2><h2 id="question"></h2>
<div class="choice-container">
<p class="choice-prefix">A</p>
<p class="choice-text" data-number="1"></p>
Expand Down
26 changes: 24 additions & 2 deletions Light/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const game = document.getElementById('game');
const time_line = document.querySelector(".time .time_line");
const timeText = document.querySelector(".timer .time_left_txt");
const timeCount = document.querySelector(".timer .timer_sec");

const question1 = document.getElementById('question1');

var soundCorrect = new Audio("sounds/correctAns.mp3");
var soundIncorrect = new Audio("sounds/wrongAns.mp3");
Expand Down Expand Up @@ -84,6 +84,7 @@ getNewQuestion = () => {
return window.location.assign('end.html');
}
questionCounter++;
question1.innerText = `Question ${questionCounter}`;//update question number
progressText.innerText = `Question ${questionCounter}/${MAX_QUESTIONS}`;
//Update the progress bar
progressBarFull.style.width = `${(questionCounter / MAX_QUESTIONS) * 100}%`;
Expand Down Expand Up @@ -129,8 +130,9 @@ choices.forEach((choice) => {
soundCorrect.play();
} else {
soundIncorrect.play();
display(currentQuestion.answer);
}

setInterval(displaynone,4000);
selectedChoice.parentElement.classList.add(classToApply);
setTimeout(() => {
selectedChoice.parentElement.classList.remove(classToApply);
Expand Down Expand Up @@ -178,7 +180,27 @@ function startTimerLine(time) {
}
}
}
let string;
function display(string) {
let display = document.getElementById('display');
if (string == 1) {
display.innerText = `Correct option : A`;
}
if (string == 2) {
display.innerText = `Correct option : B`;
}
if (string == 3) {
display.innerText = `Correct option : C`;
}
if (string == 4) {
display.innerText = `Correct option : D`;
}

}
function displaynone() {
let display = document.getElementById('display');
display.innerText = `Correct option : `;
}
incrementScore = (num) => {
score += num;
scoreText.innerText = score;
Expand Down
144 changes: 0 additions & 144 deletions game.js

This file was deleted.

0 comments on commit 60301d7

Please sign in to comment.