Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add detailed README file #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Simon Game

This project is a web-based implementation of the classic Simon Game. Test your memory and see how long you can remember the sequence of colors!

## Table of Contents
- [Introduction](#introduction)
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Code Explanation](#code-explanation)
- [Contributing](#contributing)
- [License](#license)

## Introduction

The Simon Game is a popular memory game where the player must repeat an increasingly long sequence of colors. The game starts with one color, and each round adds a new color to the sequence. The player loses if they press the wrong color.

## Features

- Simple and intuitive user interface.
- Real-time feedback with animations and sounds.
- Incremental difficulty as the game progresses.
- Game-over state with a restart option.

## Installation

To run the game locally, follow these steps:

1. Clone the repository:
```bash
git clone https://github.com/subhamsam007/Simon-Game.git
```
2. Navigate to the project directory:
```bash
cd Simon-Game
```
3. Open the `index.html` file in your web browser.

## Usage

1. Press any key to start the game.
2. Follow the sequence of colors displayed by the game.
3. Click on the buttons to repeat the sequence in the correct order.
4. If you make a mistake, the game will display "Game Over, Press Any Key to Restart" and you can start over by pressing any key.

## Code Explanation

### Variables

- `buttonColours`: An array containing the colors used in the game.
- `gamePattern`: The sequence of colors generated by the game.
- `userClickedPattern`: The sequence of colors clicked by the user.
- `started`: A boolean to check if the game has started.
- `level`: Tracks the current level of the game.

### Functions

- **`nextSequence()`**: Generates the next color in the sequence, updates the level, and displays the sequence.
- **`checkAnswer(currentLevel)`**: Checks the user's answer against the game sequence. If correct, it progresses to the next level. If incorrect, it triggers the game-over state.
- **`playSound(name)`**: Plays the sound associated with a given color.
- **`animatePress(currentColor)`**: Adds and removes the "pressed" animation to a button.
- **`startOver()`**: Resets the game variables to restart the game.

### Event Listeners

- **`$(document).keypress`**: Starts the game on any key press.
- **`$(".btn").click`**: Handles the button clicks by the user, updating the user pattern and checking the answer.

## Contributing

Contributions are welcome! If you have suggestions or improvements, feel free to fork the repository, make your changes, and submit a pull request.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

---

Feel free to customize and expand on this README to better fit your needs! If you have any more questions or need further assistance, just let me know! 😊