Skip to content

sakshi13-m/Tic-Tac-Toe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tic Tac Toe - Click me to Play!

A simple and classic Tic Tac Toe game built with Vanilla JavaScript, featuring a win and draw counter for an enhanced gaming experience.

Features

  • Two-Player Mode: Play against a friend on the same device.
  • Win and Draw Counter: Keeps track of the number of wins for each player and the total draws.
  • Responsive Design: Optimized for both desktop and mobile devices.
  • Winning Logic: Automatically detects wins, draws, and updates the counters.
  • Restart Option: Reset the board while retaining the win and draw counters.

How to Play

  1. Player 1 starts as "X," and Player 2 plays as "O."
  2. Players take turns clicking on an empty square to place their mark.
  3. The first player to align three marks horizontally, vertically, or diagonally wins.
  4. After each game, the win counter updates for the winner, or the draw counter increments if no one wins.
  5. Click the "Restart" button to start a new game.

Installation

To run the game locally:

  1. Clone the repository:

    git clone https://github.com/sakshi13-m/game.git  
  2. Navigate to the project directory:

    cd game  
  3. Open the index.html file in any modern web browser:

    file://path-to-your-folder/index.html  
    

No additional setup is required as this project is built with Vanilla JavaScript.

File Structure

game/  
├── index.html    # Main HTML file  
├── style.css     # Stylesheet for the game design  
└── script.js     # JavaScript for game logic and counters  

Key Features in script.js

  • Win Detection: Checks rows, columns, and diagonals for winning combinations.
  • Counter Logic: Updates and displays the win count for Player 1 and Player 2, along with total draws.
  • Dynamic Reset: Resets the board while retaining the counters for uninterrupted tracking.

Contribution

Contributions are welcome! Feel free to:

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature-name).
  3. Commit your changes (git commit -m "Add some feature").
  4. Push to the branch (git push origin feature-name).
  5. Open a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

If you have any questions or suggestions, feel free to reach out:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published