simplified game start logic - removed attract mode complexity
This commit is contained in:
54
pacman.html
54
pacman.html
@@ -834,42 +834,21 @@
|
|||||||
function handleSpaceButton() {
|
function handleSpaceButton() {
|
||||||
console.log('Space button pressed, current game state:', gameState);
|
console.log('Space button pressed, current game state:', gameState);
|
||||||
|
|
||||||
// Force game to start regardless of current state for testing
|
// Simple direct logic - just start the game
|
||||||
gameState = 'READY';
|
gameState = 'PLAYING';
|
||||||
readyTimer = 180;
|
|
||||||
startScreenElement.style.display = 'none';
|
startScreenElement.style.display = 'none';
|
||||||
|
gameOverElement.style.display = 'none';
|
||||||
resetPositions();
|
resetPositions();
|
||||||
soundSystem.play('ready');
|
|
||||||
console.log('Force switched to READY state');
|
console.log('Game started in PLAYING state');
|
||||||
updateDebugInfo();
|
updateDebugInfo();
|
||||||
|
|
||||||
// Original logic (commented out for testing)
|
// Play sound if available
|
||||||
/*
|
try {
|
||||||
if (gameState === 'ATTRACT') {
|
|
||||||
gameState = 'START';
|
|
||||||
attractModeTimer = 0;
|
|
||||||
soundSystem.play('ready');
|
soundSystem.play('ready');
|
||||||
console.log('Switched to START state');
|
} catch (e) {
|
||||||
} else if (gameState === 'START') {
|
console.log('Sound not available:', e);
|
||||||
gameState = 'READY';
|
|
||||||
readyTimer = 180;
|
|
||||||
startScreenElement.style.display = 'none';
|
|
||||||
resetPositions();
|
|
||||||
soundSystem.play('ready');
|
|
||||||
console.log('Switched to READY state');
|
|
||||||
} else if (gameState === 'GAME_OVER') {
|
|
||||||
gameState = 'START';
|
|
||||||
gameOverElement.style.display = 'none';
|
|
||||||
score = 0;
|
|
||||||
lives = 3;
|
|
||||||
currentLevel = 1;
|
|
||||||
updateScore();
|
|
||||||
updateLives();
|
|
||||||
maze = JSON.parse(JSON.stringify(mazeLayout));
|
|
||||||
soundSystem.play('ready');
|
|
||||||
console.log('Restarted game');
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize mobile controls if needed
|
// Initialize mobile controls if needed
|
||||||
@@ -899,9 +878,20 @@
|
|||||||
handleSpaceButton();
|
handleSpaceButton();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Start with attract mode
|
// Start with START state instead of ATTRACT for easier testing
|
||||||
gameState = 'ATTRACT';
|
gameState = 'START';
|
||||||
attractModeTimer = 0;
|
attractModeTimer = 0;
|
||||||
|
|
||||||
|
// Show start screen immediately
|
||||||
|
startScreenElement.style.display = 'block';
|
||||||
|
|
||||||
|
console.log('Game starting in START state');
|
||||||
|
console.log('Start screen visible:', startScreenElement.style.display);
|
||||||
|
|
||||||
|
// Test if JavaScript is working
|
||||||
|
alert('JavaScript is loaded! Click OK to continue.');
|
||||||
|
|
||||||
|
// Start game loop
|
||||||
gameLoop();
|
gameLoop();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user