Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Akanchha112 authored Jan 15, 2024
2 parents f6bf303 + e63e609 commit e92f2ea
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
21 changes: 17 additions & 4 deletions Dark/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ 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");
var myMusic = new Audio("sounds/gametheme.mp3");
Expand All @@ -26,7 +28,6 @@ let widthValue = 0;

let questions = [];


fetch(
'https://opentdb.com/api.php?amount=10&category=17&difficulty=easy&type=multiple'
)
Expand Down Expand Up @@ -60,7 +61,7 @@ fetch(
console.error(err);
});

//CONSTANTS
// CONSTANTS
const CORRECT_BONUS = 10;
const MAX_QUESTIONS = 10;

Expand Down Expand Up @@ -125,8 +126,18 @@ choices.forEach((choice) => {
clearInterval(counter);
clearInterval(counterLine);

const timeRemaining = parseInt(timeCount.textContent);

if (classToApply === 'correct') {
incrementScore(CORRECT_BONUS);
let scoreToAdd = 0;
if (timeRemaining > 10 && timeRemaining <= 15) {
scoreToAdd = 10;
} else if (timeRemaining > 5 && timeRemaining <= 10) {
scoreToAdd = 5;
} else if (timeRemaining > 0 && timeRemaining <= 5) {
scoreToAdd = 2;
}
incrementScore(scoreToAdd);
soundCorrect.play();
} else {
soundIncorrect.play();
Expand All @@ -147,7 +158,8 @@ choices.forEach((choice) => {
function startTimer(time) {
counter = setInterval(timer, 1000);
function timer() {
timeCount.textContent = time; time--;
timeCount.textContent = time;
time--;
if (time < 9) {
let addZero = timeCount.textContent;
timeCount.textContent = "0" + addZero;
Expand Down Expand Up @@ -207,6 +219,7 @@ incrementScore = (num) => {
score += num;
scoreText.innerText = score;
};

var count=0;
function muteMe(elem) {
elem.muted = true;
Expand Down
21 changes: 17 additions & 4 deletions Light/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ 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");
var myMusic = new Audio("sounds/gametheme.mp3");
Expand All @@ -26,7 +28,6 @@ let widthValue = 0;

let questions = [];


fetch(
'https://opentdb.com/api.php?amount=10&category=17&difficulty=easy&type=multiple'
)
Expand Down Expand Up @@ -60,7 +61,7 @@ fetch(
console.error(err);
});

//CONSTANTS
// CONSTANTS
const CORRECT_BONUS = 10;
const MAX_QUESTIONS = 10;

Expand Down Expand Up @@ -125,8 +126,18 @@ choices.forEach((choice) => {
clearInterval(counter);
clearInterval(counterLine);

const timeRemaining = parseInt(timeCount.textContent);

if (classToApply === 'correct') {
incrementScore(CORRECT_BONUS);
let scoreToAdd = 0;
if (timeRemaining > 10 && timeRemaining <= 15) {
scoreToAdd = 10;
} else if (timeRemaining > 5 && timeRemaining <= 10) {
scoreToAdd = 5;
} else if (timeRemaining > 0 && timeRemaining <= 5) {
scoreToAdd = 2;
}
incrementScore(scoreToAdd);
soundCorrect.play();
} else {
soundIncorrect.play();
Expand All @@ -145,7 +156,8 @@ choices.forEach((choice) => {
function startTimer(time) {
counter = setInterval(timer, 1000);
function timer() {
timeCount.textContent = time; time--;
timeCount.textContent = time;
time--;
if (time < 9) {
let addZero = timeCount.textContent;
timeCount.textContent = "0" + addZero;
Expand Down Expand Up @@ -205,6 +217,7 @@ incrementScore = (num) => {
score += num;
scoreText.innerText = score;
};

var count=0;
function muteMe(elem) {
elem.muted = true;
Expand Down

0 comments on commit e92f2ea

Please sign in to comment.