Private
Public Access
1
0

Refine player movement and physics constants for improved 20 TPS gameplay, add reusable config values, enhance button loading states, and prevent duplicate game starts. Update cache-busting version for client assets.
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 2m3s

This commit is contained in:
Sebastian Unterschütz
2026-01-05 21:04:39 +01:00
parent dc5136ca21
commit 66d7b6d2a5
7 changed files with 106 additions and 32 deletions

View File

@@ -1,6 +1,7 @@
// Game State
let wasmReady = false;
let gameStarted = false;
let gameStarting = false; // Verhindert doppeltes Starten
let audioMuted = false;
let currentLeaderboard = []; // Store full leaderboard data with proof codes
@@ -234,7 +235,7 @@ window.onWasmReady = function() {
};
// Cache Management - Version wird bei jedem Build aktualisiert
const CACHE_VERSION = 1767639190355; // Wird durch Build-Prozess ersetzt
const CACHE_VERSION = 1767643088942; // Wird durch Build-Prozess ersetzt
// Fetch mit Cache-Busting
async function fetchWithCache(url) {
@@ -315,7 +316,22 @@ function startSoloGame() {
return;
}
// Verhindere doppeltes Starten
if (gameStarting) {
console.log('⚠️ Game is already starting...');
return;
}
gameStarting = true;
const playerName = document.getElementById('playerName').value || 'ANON';
const startBtn = document.getElementById('startBtn');
// Button deaktivieren und Loading anzeigen
if (startBtn) {
startBtn.disabled = true;
startBtn.innerHTML = '<span class="spinner-small"></span> Starte...';
startBtn.style.opacity = '0.6';
}
// Store in localStorage for WASM to read
localStorage.setItem('escape_player_name', playerName);
@@ -341,6 +357,21 @@ function createRoom() {
return;
}
// Verhindere doppeltes Starten
if (gameStarting) {
console.log('⚠️ Game is already starting...');
return;
}
gameStarting = true;
const createBtn = document.getElementById('createRoomBtn');
// Button deaktivieren und Loading anzeigen
if (createBtn) {
createBtn.disabled = true;
createBtn.innerHTML = '<span class="spinner-small"></span> Erstelle Raum...';
createBtn.style.opacity = '0.6';
}
const playerName = document.getElementById('playerName').value || 'ANON';
const roomID = 'R' + Math.random().toString(36).substr(2, 5).toUpperCase();
const teamName = 'TEAM';
@@ -352,11 +383,16 @@ function createRoom() {
localStorage.setItem('escape_team_name', teamName);
localStorage.setItem('escape_is_host', 'true');
// Show Lobby
setUIState(UIState.LOBBY);
document.getElementById('lobbyRoomCode').textContent = roomID;
document.getElementById('lobbyHostControls').classList.remove('hidden');
document.getElementById('lobbyStatus').textContent = 'Du bist Host - starte wenn bereit!';
// Show Lobby nach kurzer Verzögerung (damit User Feedback sieht)
setTimeout(() => {
setUIState(UIState.LOBBY);
document.getElementById('lobbyRoomCode').textContent = roomID;
document.getElementById('lobbyHostControls').classList.remove('hidden');
document.getElementById('lobbyStatus').textContent = 'Du bist Host - starte wenn bereit!';
// Reset gameStarting für Lobby
gameStarting = false;
}, 300);
// Trigger WASM game start (im Hintergrund)
if (window.startGame) {
@@ -375,12 +411,34 @@ function joinRoom() {
return;
}
// Verhindere doppeltes Starten
if (gameStarting) {
console.log('⚠️ Game is already starting...');
return;
}
gameStarting = true;
const joinBtn = document.getElementById('joinRoomBtn');
// Button deaktivieren und Loading anzeigen
if (joinBtn) {
joinBtn.disabled = true;
joinBtn.innerHTML = '<span class="spinner-small"></span> Trete bei...';
joinBtn.style.opacity = '0.6';
}
const playerName = document.getElementById('playerName').value || 'ANON';
const roomID = document.getElementById('joinRoomCode').value.toUpperCase();
const teamName = document.getElementById('teamNameJoin').value || 'TEAM';
if (!roomID || roomID.length < 4) {
alert('Bitte gib einen gültigen Raum-Code ein!');
// Reset bei Fehler
gameStarting = false;
if (joinBtn) {
joinBtn.disabled = false;
joinBtn.innerHTML = 'RAUM BEITRETEN';
joinBtn.style.opacity = '1';
}
return;
}
@@ -391,11 +449,20 @@ function joinRoom() {
localStorage.setItem('escape_team_name', teamName);
localStorage.setItem('escape_is_host', 'false');
// Show Lobby
setUIState(UIState.LOBBY);
document.getElementById('lobbyRoomCode').textContent = roomID;
document.getElementById('lobbyHostControls').classList.add('hidden');
document.getElementById('lobbyStatus').textContent = 'Warte auf Host...';
// Show Lobby nach kurzer Verzögerung
setTimeout(() => {
setUIState(UIState.LOBBY);
document.getElementById('lobbyRoomCode').textContent = roomID;
document.getElementById('lobbyHostControls').classList.add('hidden');
document.getElementById('lobbyStatus').textContent = 'Warte auf Host...';
// Reset gameStarting für Lobby
gameStarting = false;
}, 300);
// Reset gameStarting für Lobby
gameStarting = false;
}, 300);
// Trigger WASM game start (im Hintergrund)
if (window.startGame) {