This is a simple implementation of the classic Tic Tac Toe game using HTML, CSS, and JavaScript. The game allows two players to take turns marking "X" or "O" on a 3x3 grid. The first player to align three of their marks in a row, column, or diagonal wins the game. If all boxes are filled without a winner, the game ends in a draw.
- Two-player gameplay: Players alternate turns to play as "X" or "O".
- Winner Detection: Automatically detects and announces the winner.
- Draw Detection: Announces a draw if all boxes are filled without a winner.
- Reset Button: Allows players to restart the current game.
- New Game Button: Resets the game and clears the message container for a fresh start.
- Interactive UI: Dynamic updates to the board with visual feedback for player moves.
- HTML: For the game layout.
- CSS: For styling the board and game elements.
- JavaScript: For game logic, event handling, and winner/draw detection.
- Clone or download the repository to your local machine.
- Open the
index.html
file in any modern web browser. - Start playing!
- The game starts with Player 1 (“X”) taking the first turn.
- Players alternate turns, marking one empty box per turn.
- The first player to get three marks in a row, column, or diagonal wins.
- If all boxes are filled and no player has won, the game ends in a draw.
index.html
: The main HTML file containing the game layout.style.css
: The CSS file for styling the game.script.js
: The JavaScript file containing the game logic.
- Players click on empty boxes to place their marks ("X" or "O").
- The game checks for a winner or a draw after each move:
- If three identical marks are aligned (row, column, or diagonal), the game announces the winner.
- If all boxes are filled and no winner is found, it declares a draw.
- Players can use the Reset button to restart the current game or the New Game button for a fresh start.
Add screenshots of the game board, winner announcement, and draw announcement for better visualization.
- Add a score counter to keep track of wins for both players.
- Implement AI for a single-player mode.
- Enhance the UI with animations and better styling.
- Add a timer to limit the time for each turn.
Contributions are welcome! If you'd like to improve the game, feel free to fork the repository and submit a pull request.
This project is open-source and available under the MIT License.
Special thanks to anyone who plays this game and provides feedback for its improvement!