Skip to content

Commit b6b11d2

Browse files
adding of points distribution (#70)
* adding of points distribution * changes on point distribution * changes done on points distribution and bonus points * Revert "Merge branch 'main' into main" This reverts commit ef2e06f, reversing changes made to a776997. --------- Co-authored-by: Kendall <kendalldoescoding@gmail.com>
1 parent 06f0061 commit b6b11d2

File tree

33 files changed

+719
-519
lines changed

33 files changed

+719
-519
lines changed

css/game.css

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,34 @@ body {
7979
background: rgb(11, 223, 36);
8080
width: 0%;
8181
}
82+
.green-score{
83+
color: green;
84+
}
85+
.red-score{
86+
color:red;
87+
}
88+
89+
#addPoints{
90+
display:none;
91+
position: relative;
92+
right:90px;
93+
color:green;
94+
font-size: 20px;
95+
top: -100px;
96+
animation: ripple-animation 0.6s linear;
97+
}
98+
#subPoints{
99+
display:none;
100+
position: relative;
101+
right:90px;
102+
color:red;
103+
font-size: 20px;
104+
top: -100px;
105+
animation: ripple-animation 0.6s linear;
106+
}
107+
@keyframes ripple-animation {
108+
to {
109+
transform: scale(2);
110+
opacity: 0;
111+
}
112+
}

css/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ input::placeholder {
211211
font-size: 2.3rem;
212212
text-align: center;
213213
padding-bottom: 2.4rem;
214+
cursor: pointer;
214215
}
215216

216217
.back-btn {

css/topics.css

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,6 @@ background-image: linear-gradient(
159159
);
160160
}
161161

162-
#instrum-btn {
163-
background-color: #85FFBD;
164-
background-image: linear-gradient(45deg, #85FFBD 0%, #FFFB7D 100%);
165-
}
166-
167-
168162
#jaidenanimations-btn {
169163
background-color: #4158D0;
170164
background-image: linear-gradient(43deg, #4158D0 0%, #C850C0 46%, #FFCC70 100%);

js/QuizClass.js

Lines changed: 101 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ export class Quiz {
77
this.QUESTION_VALUE = 100;
88
this.QUESTIONS_AMOUNT = dataQA.length;
99
this.barPercetage = 0;
10+
this.streakPoints = 0;
11+
this.timePoints = 0;
1012
this.score = 0;
1113
this.answer = "";
1214
this.canClick = true;
1315
this.noOfCorrect = 0;
1416
this.TOTAL_CORRECT = 0;
15-
17+
1618
this.correctStreak = 0; // Tracks consecutive correct answers
1719
this.startTime = 0; // Stores the start time of each question
1820
// runs here because we want to load the first round of questions
@@ -92,9 +94,13 @@ export class Quiz {
9294
this._updateCorrectCount();
9395
this.calculateTimeBonus();
9496
this.updateStreak();
97+
document.getElementById('score').classList.add('green-score');
98+
document.getElementById('addPoints').style.display = 'block';
9599
} else {
96100
p.parentElement.classList.add("incorrect");
97101
this.score -= this.QUESTION_VALUE;
102+
document.getElementById('score').classList.add('red-score');
103+
document.getElementById('subPoints').style.display = 'block';
98104
}
99105

100106
document.getElementById("score").textContent = this.score;
@@ -106,6 +112,10 @@ export class Quiz {
106112
this.canClick = true;
107113
p.parentElement.classList.remove("incorrect");
108114
p.parentElement.classList.remove("correct");
115+
document.getElementById('score').classList.remove('green-score');
116+
document.getElementById('score').classList.remove('red-score');
117+
document.getElementById('subPoints').style.display = 'none';
118+
document.getElementById('addPoints').style.display = 'none';
109119
}, 600);
110120
}
111121

@@ -118,10 +128,13 @@ export class Quiz {
118128

119129
if (elapsed <= 1000) {
120130
this.score += 1000;
121-
} else if (elapsed <= 5000) {
131+
this.timePoints = 1000;
132+
} else if (elapsed <= 5000) {
122133
this.score += 500;
134+
this.timePoints = 500;
123135
} else if (elapsed <= 10000) {
124136
this.score += 100;
137+
this.timePoints = 100;
125138
}
126139
}
127140

@@ -130,18 +143,100 @@ export class Quiz {
130143

131144
if (this.correctStreak === 2) {
132145
this.score += 200;
146+
this.streakPoints = 300;
147+
this.bonusPoints = this.streakPoints + this.timePoints
148+
this.displayText = "+" + this.bonusPoints;
149+
document.getElementById("addPoints").textContent = this.displayText;
133150
} else if (this.correctStreak === 3) {
134151
this.score += 300;
135-
} else if (this.correctStreak === 5) {
152+
this.streakPoints = 400;
153+
this.bonusPoints = this.streakPoints + this.timePoints
154+
this.displayText = "+" + this.bonusPoints;
155+
document.getElementById("addPoints").textContent = this.displayText;
156+
} else if (this.correctStreak === 4) {
157+
this.score += 300;
158+
this.streakPoints = 400;
159+
this.bonusPoints = this.streakPoints + this.timePoints
160+
this.displayText = "+" + this.bonusPoints;
161+
document.getElementById("addPoints").textContent = this.displayText;
162+
}else if (this.correctStreak === 5) {
163+
this.score += 800;
164+
this.streakPoints = 900;
165+
this.bonusPoints = this.streakPoints + this.timePoints
166+
this.displayText = "+" + this.bonusPoints;
167+
document.getElementById("addPoints").textContent = this.displayText;
168+
} else if (this.correctStreak === 6) {
169+
this.score += 800;
170+
this.streakPoints = 900;
171+
this.bonusPoints = this.streakPoints + this.timePoints
172+
this.displayText = "+" + this.bonusPoints;
173+
document.getElementById("addPoints").textContent = this.displayText;
174+
}else if (this.correctStreak === 7) {
175+
this.score += 800;
176+
this.streakPoints = 900;
177+
this.bonusPoints = this.streakPoints + this.timePoints
178+
this.displayText = "+" + this.bonusPoints;
179+
document.getElementById("addPoints").textContent = this.displayText;
180+
}else if (this.correctStreak === 8) {
181+
this.score += 800;
182+
this.streakPoints = 900;
183+
this.bonusPoints = this.streakPoints + this.timePoints
184+
this.displayText = "+" + this.bonusPoints;
185+
document.getElementById("addPoints").textContent = this.displayText;
186+
}else if (this.correctStreak === 9) {
136187
this.score += 800;
137-
} else if (this.correctStreak === 10) {
188+
this.streakPoints = 900;
189+
this.bonusPoints = this.streakPoints + this.timePoints
190+
this.displayText = "+" + this.bonusPoints;
191+
document.getElementById("addPoints").textContent = this.displayText;
192+
}else if (this.correctStreak === 10) {
138193
this.score += 1200;
194+
this.streakPoints = 1300;
195+
this.bonusPoints = this.streakPoints + this.timePoints
196+
this.displayText = "+" + this.bonusPoints;
197+
document.getElementById("addPoints").textContent = this.displayText;
198+
}else if (this.correctStreak === 11) {
199+
this.score += 1200;
200+
this.streakPoints = 1300;
201+
this.bonusPoints = this.streakPoints + this.timePoints
202+
this.displayText = "+" + this.bonusPoints;
203+
document.getElementById("addPoints").textContent = this.displayText;
204+
}else if (this.correctStreak === 12) {
205+
this.score += 1200;
206+
this.streakPoints = 1300;
207+
this.bonusPoints = this.streakPoints + this.timePoints
208+
this.displayText = "+" + this.bonusPoints;
209+
document.getElementById("addPoints").textContent = this.displayText;
210+
}else if (this.correctStreak === 13) {
211+
this.score += 1200;
212+
this.streakPoints = 1300;
213+
this.bonusPoints = this.streakPoints + this.timePoints
214+
this.displayText = "+" + this.bonusPoints;
215+
document.getElementById("addPoints").textContent = this.displayText;
216+
}else if (this.correctStreak === 14) {
217+
this.score += 1200;
218+
this.streakPoints = 1300;
219+
this.bonusPoints = this.streakPoints + this.timePoints
220+
this.displayText = "+" + this.bonusPoints;
221+
document.getElementById("addPoints").textContent = this.displayText;
139222
} else if (this.correctStreak === 15) {
140223
this.score += 1500;
224+
this.streakPoints = 1600;
225+
this.bonusPoints = this.streakPoints + this.timePoints
226+
this.displayText = "+" + this.bonusPoints;
227+
document.getElementById("addPoints").textContent = this.displayText;
141228
} else if (this.correctStreak > 15) {
142229
this.score += 1500; // Add 1500 points for each additional correct answer beyond 15
143-
} else {
144-
this.correctStreak = 1; // Reset the streak if the answer is not consecutive
230+
this.streakPoints = 1600;
231+
this.bonusPoints = this.streakPoints + this.timePoints
232+
this.displayText = "+" + this.bonusPoints;
233+
document.getElementById("addPoints").textContent = this.displayText;
234+
} else if (this.correctStreak = 1){
235+
this.score += 100;// Reset the streak if the answer is not consecutive
236+
this.streakPoints = 200;
237+
this.bonusPoints = this.streakPoints + this.timePoints
238+
this.displayText = "+" + this.bonusPoints;
239+
document.getElementById("addPoints").textContent = this.displayText;
145240
}
146241
}
147242
}

js/christmas-songs.js

Lines changed: 40 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,46 @@
1-
// Song URL
2-
const songs = [
3-
"/music/christmas/AVeryMogulChristmas.mp3",
4-
"/music/christmas/FelizNavidad.mp3",
5-
"/music/christmas/DeckTheHalls.mp3",
6-
"/music/christmas/It'sThatTimeOfTheYear.mp3",
7-
];
8-
9-
// Initialize DOM variables
10-
let audioElement = document.getElementById("my_audio");
11-
let musicOnButton = document.getElementById("musicOnButton");
12-
let musicOffButton = document.getElementById("musicOffButton");
13-
14-
// Define the playMusic function, handling the music
15-
const playMusic = () => {
16-
// Define the song and its URL
17-
let randomIndex = Math.floor(Math.random() * songs.length);
18-
let audioSource = document.getElementById("audio_source");
19-
20-
// Load the song info into the audioElement
21-
audioSource.src = songs[randomIndex];
22-
audioElement.load();
23-
24-
// Update the AudioElement to handle playing the song
25-
audioElement.addEventListener(
26-
"canplaythrough",
27-
() => {
28-
try {
29-
audioElement.play();
30-
musicOnButton.style.display = "none";
31-
musicOffButton.style.display = "block";
32-
} catch (err) {
1+
var songs = [
2+
"/music/christmas/AVeryMogulChristmas.mp3",
3+
"/music/christmas/FelizNavidad.mp3",
4+
"/music/christmas/DeckTheHalls.mp3",
5+
"/music/christmas/It'sThatTimeOfTheYear.mp3",
6+
];
7+
8+
var audioElement = document.getElementById('my_audio');
9+
var musicOnButton = document.getElementById('musicOnButton');
10+
11+
function playMusic() {
12+
var randomIndex = Math.floor(Math.random() * songs.length);
13+
var audioSource = document.getElementById('audio_source');
14+
audioSource.src = songs[randomIndex];
15+
audioElement.load();
16+
17+
audioElement.addEventListener('canplaythrough', function() {
18+
audioElement.play().catch(function(error) {
19+
console.log('Error playing audio:', error);
3320
pauseMusic();
34-
throw err;
35-
}
36-
},
37-
{ once: true }
38-
);
21+
});
22+
musicOnButton.style.display = 'none';
23+
}, { once: true });
3924

40-
// Update the AudioElement to handle pausing the song
41-
audioElement.addEventListener("pause", function () {
42-
musicOnButton.style.display = "block";
43-
musicOffButton.style.display = "none";
44-
});
45-
};
25+
audioElement.addEventListener('pause', function() {
26+
musicOnButton.style.display = 'block';
27+
});
28+
}
4629

47-
// Define the pauseMusic function, handling the commands to stop the music
48-
const pauseMusic = () => {
49-
audioElement.pause();
50-
musicOnButton.style.display = "block";
51-
musicOffButton.style.display = "none";
52-
};
30+
function pauseMusic() {
31+
audioElement.pause();
32+
musicOnButton.style.display = 'block';
33+
}
5334

54-
// Define the toggleMusic function, handling the commands to toggle
55-
// the buttons "musicOnButton" and "musicOffButton"
56-
const toggleMusic = () => {
57-
if (audioElement.paused) {
58-
playMusic();
59-
} else {
60-
pauseMusic();
35+
function toggleMusic() {
36+
if (audioElement.paused) {
37+
playMusic();
38+
} else {
39+
pauseMusic();
40+
}
6141
}
62-
};
6342

64-
// Play music on page load
65-
window.addEventListener("load", () => {
66-
playMusic();
67-
});
43+
// Play music on page load
44+
window.addEventListener('load', function() {
45+
playMusic();
46+
});

js/data/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import footballQA from "./football.js";
2020

2121
import fruitQA from "./fruit.js";
2222
import generalQA from "./general.js";
23-
import instrumentsQA from "./instruments.js";
2423
import kendallQA from "./kendall_quiz.js";
2524

2625
import minecraftQA from "./minecraft.js";
@@ -46,7 +45,6 @@ export {
4645
footballQA,
4746
fruitQA,
4847
generalQA,
49-
instrumentsQA,
5048
kendallQA,
5149
minecraftQA,
5250
presidentsQA,
@@ -57,4 +55,4 @@ export {
5755
youtubeQA,
5856
TheOdd1sOutQA,
5957
JaidenAnimationsQA,
60-
};
58+
};

0 commit comments

Comments
 (0)