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
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();
};
// Test 2: Add a simple click handler
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
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initializeGame);
} else {
// DOM already loaded
initializeGame();
}
// Change background to show something happened
document.body.style.backgroundColor = '#ff0000';
// Additional fallback for Chrome Android
window.addEventListener('load', function() {
console.log('Page fully loaded');
if (!gameLoopStarted) {
console.log('Fallback initialization');
initializeGame();
}
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 ===');
}
// Run simple test immediately
simpleTest();
</script>
</body>
</html>