about summary refs log tree commit diff stats
path: root/html/mountain
diff options
context:
space:
mode:
Diffstat (limited to 'html/mountain')
-rw-r--r--html/mountain/game.js22
1 files changed, 20 insertions, 2 deletions
diff --git a/html/mountain/game.js b/html/mountain/game.js
index 6c5737f..39fff3b 100644
--- a/html/mountain/game.js
+++ b/html/mountain/game.js
@@ -457,6 +457,18 @@ function killPlayer() {
     }
 }
 
+// Try to compensate for varying viewport widths
+function calculateTimeLimit(isSuper) {
+    const baseLimit = isSuper ? SUPER_HARD_MODE_TIME_LIMIT : HARD_MODE_TIME_LIMIT;
+    
+    if (canvas.width <= 2000) return baseLimit;
+    
+    const extraWidth = canvas.width - 2000;
+    const extraSeconds = Math.floor(extraWidth / 1000) * (isSuper ? 0.5 : 1);
+    
+    return baseLimit + extraSeconds;
+}
+
 function updatePlayer() {
     if (gameState === GAME_STATE.GAME_OVER) {
         if (deathAnimationTimer <= 0 && keys['Enter']) {
@@ -465,7 +477,10 @@ function updatePlayer() {
         return;
     }
 
-    const timeLimit = superHardMode ? SUPER_HARD_MODE_TIME_LIMIT : HARD_MODE_TIME_LIMIT;
+    const timeLimit = superHardMode ? 
+        calculateTimeLimit(true) : 
+        calculateTimeLimit(false);
+        
     if ((hardMode || superHardMode) && Date.now() - levelStartTime > timeLimit * 1000) {
         killPlayer();
         return;
@@ -586,7 +601,10 @@ function resizeCanvas() {
 
 function draw(currentTime) {
     if ((hardMode || superHardMode) && gameState === GAME_STATE.PLAYING) {
-        const timeLimit = superHardMode ? SUPER_HARD_MODE_TIME_LIMIT : HARD_MODE_TIME_LIMIT;
+        const timeLimit = superHardMode ? 
+            calculateTimeLimit(true) : 
+            calculateTimeLimit(false);
+            
         const timeElapsed = Date.now() - levelStartTime;
         const timeRemaining = Math.max(0, timeLimit * 1000 - timeElapsed);
         const progressRatio = timeRemaining / (timeLimit * 1000);