Skip to content

Commit 7eae8d3

Browse files
committed
version 1.4.0.1
1 parent 1b72557 commit 7eae8d3

File tree

2 files changed

+172
-166
lines changed

2 files changed

+172
-166
lines changed

Levels/gameloader.html

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,9 @@ <h2>Game Paused</h2>
927927
levelMusic = URL.createObjectURL(blob);
928928
} else if (isPracticeMode) {
929929
levelMusic = '../Sound/Basic Soundeffects/practicetd.ogg';
930+
} else if (data.musicValue && data.musicValue.startsWith('../Sound/Level Soundtracks/')) {
931+
levelMusic = `${data.musicValue}`;
932+
console.log("Level Soundtrack: ", levelMusic);
930933
} else if (data.musicValue) {
931934
levelMusic = `../Sound/Level Soundtracks/${data.musicValue}`;
932935
console.log("Level Soundtrack: ", levelMusic);
@@ -1977,36 +1980,39 @@ <h2>Game Paused</h2>
19771980
* Called from updateGame when new obstacles are created
19781981
* Throttled to avoid performance issues
19791982
*/
1980-
function updateProgress() {
1983+
function updateProgress() {
19811984
if (!levelMatrix || levelMatrix.length === 0) return;
19821985

19831986
const currentTime = Date.now();
19841987
if (currentTime - lastProgressUpdate < progressUpdateInterval) return;
19851988

19861989
// Calculate progress based on current column position
1987-
let progress = 0;
1988-
if (totalBlocks > 0) {
1989-
progress = Math.min((passedBlocks / totalBlocks) * 100, 100);
1990-
}
1991-
const numSections = colorSteps.length - 1;
1992-
const sectionSize = 100 / numSections;
1993-
colorIndex = Math.min(Math.floor(progress / sectionSize), numSections - 1);
1994-
const sectionStart = colorIndex * sectionSize;
1995-
transitionFactor = (progress - sectionStart) / sectionSize;
1990+
const totalColumns = levelMatrix[0].length;
1991+
const delayColumns = 3; // Creates a 2-second delay for smoother progress
1992+
const adjustedColumn = Math.max(0, currentColumn - delayColumns);
1993+
1994+
// Calculate progress with finer granularity
1995+
const progress = (adjustedColumn / totalColumns) * 100;
1996+
const clampedProgress = Math.min(Math.round(progress), 99); // Cap at 99% until complete
1997+
1998+
// Only show 100% when level is actually complete
1999+
const finalProgress = isLevelComplete ? 100 :
2000+
progress >= 98 ? 99 : // Force 99% when near the end
2001+
clampedProgress;
19962002

19972003
// Update UI elements
19982004
const progressText = document.getElementById('progressText');
19992005
const progressFill = document.getElementById('progressFill');
20002006

2001-
progressText.textContent = `${progress}%`;
2002-
progressFill.style.width = `${progress}%`;
2007+
progressText.textContent = `${finalProgress}%`;
2008+
progressFill.style.width = `${finalProgress}%`;
20032009

20042010
// Update progress bar colors based on completion
2005-
if (progress > 75) {
2011+
if (finalProgress > 75) {
20062012
progressFill.style.background = 'linear-gradient(90deg, #00ff00, #4287f5)';
2007-
} else if (progress > 50) {
2013+
} else if (finalProgress > 50) {
20082014
progressFill.style.background = 'linear-gradient(90deg, #ffff00, #00ff00)';
2009-
} else if (progress > 25) {
2015+
} else if (finalProgress > 25) {
20102016
progressFill.style.background = 'linear-gradient(90deg, #ffa500, #ffff00)';
20112017
}
20122018

@@ -2015,8 +2021,8 @@ <h2>Game Paused</h2>
20152021
if (heightIndicator) {
20162022
const indicatorHeight = heightIndicator.offsetHeight;
20172023
const playerIndicator = document.getElementById('playerIndicator');
2018-
const position = (progress / 100) * indicatorHeight;
2019-
playerIndicator.style.top = `${Math.min(heightIndicator.offsetHeight, Math.max(0, position))}px`;
2024+
const position = (finalProgress / 100) * indicatorHeight;
2025+
playerIndicator.style.top = `${position}px`;
20202026
}
20212027

20222028
lastProgressUpdate = currentTime;

0 commit comments

Comments
 (0)