Core Logic Modules gamePattern[]: Stores system-generated color sequence.
userClickedPattern[]: Stores player’s input.
nextSequence(): Adds a new random color to the sequence each level.
checkAnswer(): Verifies if the user input matches the system pattern.
startOver(): Resets state after a wrong input.
✨ Features
🎮 Core Features Color Sequence Generation
Randomly generates and displays a sequence of colored buttons (e.g., red, blue, green, yellow).
User Interaction
User clicks the color buttons in the same order as shown.
Clicks are visually highlighted and optionally have sound effects.
Progressive Difficulty
Sequence gets longer with each level, increasing the challenge.
Level Tracking
Displays current level (e.g., “Level 3”) to show progression.
Input Validation
Realtime check of user’s input against the correct sequence.
Immediate feedback for wrong input (e.g., red flash or “Game Over” text).
Game Over & Restart
Automatically resets the game on wrong input and prompts the user to restart.
🔧 Technical Features State Management
Tracks gamePattern[], userClickedPattern[], and game status flags (like started).
Keyboard/Touch Input (optional)
Allows playing with keyboard keys (like A, S, D, F) or on touch devices.
Start Trigger
Game starts on a keypress or button click (instead of auto-starting).
Separation of Logic
Modular functions like startGame(), nextSequence(), checkAnswer() keep the code maintainable.