added simple test to isolate button click issues

This commit is contained in:
2026-02-02 17:14:28 +00:00
parent d48e9fa27b
commit 24108d949a

View File

@@ -904,69 +904,39 @@
} }
} }
// Initialize game for Chrome Android // Ultra-simple test for Chrome Android
function initializeGame() { function simpleTest() {
console.log('Initializing game for Chrome Android...'); console.log('=== SIMPLE TEST START ===');
// Force show mobile controls // Test 1: Check if elements exist
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...');
console.log('Space button element:', mobileSpaceBtnElement); console.log('Space button element:', mobileSpaceBtnElement);
console.log('Space button visible:', mobileSpaceBtnElement.style.display !== 'none'); console.log('Start screen element:', startScreenElement);
console.log('Mobile controls element:', mobileControlsElement); console.log('Canvas element:', canvas);
console.log('Mobile controls visible:', mobileControlsElement.classList.contains('active'));
// Test space button // Test 2: Add a simple click handler
handleSpaceButton(); mobileSpaceBtnElement.addEventListener('click', function(e) {
}; console.log('CLICK DETECTED!');
alert('Space button clicked! Game should start now.');
let gameLoopStarted = false; // Hide start screen
startScreenElement.style.display = 'none';
// Initialize on page load with fallback for Chrome Android // Change background to show something happened
if (document.readyState === 'loading') { document.body.style.backgroundColor = '#ff0000';
document.addEventListener('DOMContentLoaded', initializeGame);
} else {
// DOM already loaded
initializeGame();
}
// Additional fallback for Chrome Android console.log('Game started!');
window.addEventListener('load', function() {
console.log('Page fully loaded');
if (!gameLoopStarted) {
console.log('Fallback initialization');
initializeGame();
}
}); });
// Test 3: Add visual feedback
mobileSpaceBtnElement.style.backgroundColor = '#00ff00';
mobileSpaceBtnElement.style.color = '#000000';
mobileSpaceBtnElement.textContent = 'CLICK ME!';
console.log('=== SIMPLE TEST SETUP COMPLETE ===');
}
// Run simple test immediately
simpleTest();
</script> </script>
</body> </body>
</html> </html>