A simple implementation of the Simon game using jQuery.
Simon is a memory game where the player must remember and repeat a series of button colors shown by the game. The game starts with a single color, and with each successful round, an additional color is added to the sequence. The player must reproduce the sequence correctly to advance to the next level.
- HTML
- CSS
- JavaScript
- jQuery
How to Play
Press any key on your keyboard to start the game.
Pay attention to the color sequence shown by the game.
Click on the buttons to reproduce the sequence.
If you click the wrong color, the game will end.
Try to reach the highest level possible!
Code Explanation
The game logic is implemented using JavaScript and jQuery.
The buttonColours array stores the colors available in the game.
The gamePattern array stores the sequence generated by the game.
The userClickedPattern array stores the sequence of colors clicked by the user.
The game starts when a key is pressed, and the nextSequence function is called.
When a button is clicked, the color is added to the user's clicked pattern, and the checkAnswer function is called to verify the correctness of the input.
If the user's pattern matches the game pattern, the next level is triggered.
If the user makes a mistake, the game ends, and the player can restart by pressing any key.
Sound effects are played when buttons are clicked or when the game ends.
The animatePress function adds a visual effect to the button press.
The startOver function resets the game when restarting.