diff --git a/cmd/client/web/game.js b/cmd/client/web/game.js index 3269ed2..1e4b015 100644 --- a/cmd/client/web/game.js +++ b/cmd/client/web/game.js @@ -856,6 +856,41 @@ function restartGame() { console.log('✅ Game restarted - ready to play again'); } +// ===== FULLSCREEN ===== + +function toggleFullscreen() { + if (!document.fullscreenElement) { + document.documentElement.requestFullscreen().catch(() => {}); + } else { + document.exitFullscreen().catch(() => {}); + } +} + +function updateFullscreenBtn() { + const btn = document.getElementById('fullscreen-btn'); + if (!btn) return; + btn.textContent = document.fullscreenElement ? '✕' : '⛶'; + btn.title = document.fullscreenElement ? 'Vollbild beenden' : 'Vollbild'; +} + +document.addEventListener('fullscreenchange', updateFullscreenBtn); + +// Auto-Fullscreen beim ersten Nutzer-Klick +let autoFullscreenDone = false; +document.addEventListener('click', function requestAutoFullscreen() { + if (!autoFullscreenDone && !document.fullscreenElement) { + autoFullscreenDone = true; + document.documentElement.requestFullscreen().catch(() => {}); + } +}, { once: false, capture: true }); + +document.addEventListener('touchstart', function requestAutoFullscreenTouch() { + if (!autoFullscreenDone && !document.fullscreenElement) { + autoFullscreenDone = true; + document.documentElement.requestFullscreen().catch(() => {}); + } +}, { once: false, capture: true }); + // Export functions for WASM to call window.showMenu = showMenu; window.hideMenu = hideMenu; diff --git a/cmd/client/web/index.html b/cmd/client/web/index.html index 83643cd..3beb599 100644 --- a/cmd/client/web/index.html +++ b/cmd/client/web/index.html @@ -9,6 +9,7 @@
+