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
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 2m3s
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -291,7 +291,7 @@
|
||||
<!-- WASM Execution -->
|
||||
<script>
|
||||
// Cache-Busting für JavaScript-Dateien (wird beim Build aktualisiert)
|
||||
const BUILD_VERSION = 1767639190355;
|
||||
const BUILD_VERSION = 1767643088942;
|
||||
document.write('<script src="wasm_exec.js?v=' + BUILD_VERSION + '"><\/script>');
|
||||
document.write('<script src="game.js?v=' + BUILD_VERSION + '"><\/script>');
|
||||
</script>
|
||||
|
||||
@@ -39,6 +39,7 @@ input[type=range]{width:100%;max-width:300px}
|
||||
.setting-item span{color:#fff;font-size:14px}
|
||||
.loading-screen{position:absolute;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.95);display:flex;flex-direction:column;justify-content:center;align-items:center;z-index:9999}
|
||||
.spinner{border:8px solid #333;border-top:8px solid #fc0;border-radius:50%;width:60px;height:60px;animation:spin 1s linear infinite}
|
||||
.spinner-small{display:inline-block;border:2px solid #666;border-top:2px solid #000;border-radius:50%;width:12px;height:12px;animation:spin 1s linear infinite;vertical-align:middle;margin-right:8px}
|
||||
@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}
|
||||
#mute-btn{position:fixed;top:10px;left:10px;z-index:10000;background:rgba(0,0,0,.5);border:2px solid #555;color:#fff;font-size:20px;width:40px;height:40px;border-radius:50%;cursor:pointer;padding:0;margin:0;display:flex;align-items:center;justify-content:center;box-shadow:0 0 10px rgba(0,0,0,.5)}
|
||||
#mute-btn:hover{background:rgba(255,255,255,.2);border-color:#fff}
|
||||
|
||||
Reference in New Issue
Block a user