From 24108d949ab2886f95b099d73ab931d8684e3af4 Mon Sep 17 00:00:00 2001 From: gronod Date: Mon, 2 Feb 2026 17:14:28 +0000 Subject: [PATCH] added simple test to isolate button click issues --- pacman.html | 86 +++++++++++++++++------------------------------------ 1 file changed, 28 insertions(+), 58 deletions(-) diff --git a/pacman.html b/pacman.html index a62bb5e..452244f 100644 --- a/pacman.html +++ b/pacman.html @@ -904,69 +904,39 @@ } } - // Initialize game for Chrome Android - function initializeGame() { - console.log('Initializing game for Chrome Android...'); + // Ultra-simple test for Chrome Android + function simpleTest() { + console.log('=== SIMPLE TEST START ==='); - // Force show mobile controls - mobileControlsElement.classList.add('active'); - mobileSpaceBtnElement.style.display = 'block'; - - // Show start screen - startScreenElement.style.display = 'block'; - - // Set initial game state - gameState = 'START'; - attractModeTimer = 0; - - // Update debug info - updateDebugInfo(); - - // Setup mobile controls - if (isMobile || window.innerWidth <= 768) { - setupMobileControls(); - } - - console.log('Game initialized successfully'); - console.log('Game state:', gameState); - console.log('Mobile controls visible:', mobileControlsElement.classList.contains('active')); - console.log('Start screen visible:', startScreenElement.style.display); - - // Start game loop - gameLoop(); - gameLoopStarted = true; - } - - // Test function for mobile controls - window.testMobileControls = function() { - console.log('Testing mobile controls...'); + // Test 1: Check if elements exist console.log('Space button element:', mobileSpaceBtnElement); - console.log('Space button visible:', mobileSpaceBtnElement.style.display !== 'none'); - console.log('Mobile controls element:', mobileControlsElement); - console.log('Mobile controls visible:', mobileControlsElement.classList.contains('active')); + console.log('Start screen element:', startScreenElement); + console.log('Canvas element:', canvas); - // Test space button - handleSpaceButton(); - }; - - let gameLoopStarted = false; - - // Initialize on page load with fallback for Chrome Android - if (document.readyState === 'loading') { - document.addEventListener('DOMContentLoaded', initializeGame); - } else { - // DOM already loaded - initializeGame(); + // Test 2: Add a simple click handler + mobileSpaceBtnElement.addEventListener('click', function(e) { + console.log('CLICK DETECTED!'); + alert('Space button clicked! Game should start now.'); + + // Hide start screen + startScreenElement.style.display = 'none'; + + // Change background to show something happened + document.body.style.backgroundColor = '#ff0000'; + + console.log('Game started!'); + }); + + // Test 3: Add visual feedback + mobileSpaceBtnElement.style.backgroundColor = '#00ff00'; + mobileSpaceBtnElement.style.color = '#000000'; + mobileSpaceBtnElement.textContent = 'CLICK ME!'; + + console.log('=== SIMPLE TEST SETUP COMPLETE ==='); } - // Additional fallback for Chrome Android - window.addEventListener('load', function() { - console.log('Page fully loaded'); - if (!gameLoopStarted) { - console.log('Fallback initialization'); - initializeGame(); - } - }); + // Run simple test immediately + simpleTest();