This repository contains a simple Tic Tac Toe game implemented using HTML, CSS, and JavaScript. Players can take turns to play the classic Tic Tac Toe game on a 3x3 grid.
- Interactive Gameplay: The game allows two players to take turns by clicking on the grid cells to place their symbols ("X" or "O").
- Dynamic Game Board: The game board is dynamically generated using HTML and CSS, making it responsive and adaptable to various screen sizes.
- Real-Time Updates: The game updates in real-time to show whose turn it is, whether a player has won, or if the game ends in a draw.
- Winning Condition Detection: The game logic in game_logic.js checks for winning conditions after each move to determine if a player has won the game.
- Restart Functionality: Players can restart the game at any time by clicking the "Restart" button. This function resets the game board and sets the player text back to "Tic Tac Toe."
- Styling and Animation: The game has a visually appealing design with custom fonts and animations for the "Restart" button on hover.
- Responsive Design: The game interface is designed to be responsive, ensuring a good user experience across different devices.
- Error Handling: The game code includes error handling to prevent invalid moves and ensure smooth gameplay.
- Customizable Colors: The game uses CSS custom properties (--orange and --winner_blocks) to easily customize the color scheme.
- Modular Code Structure: The JavaScript code is organized into functions, promoting readability and maintainability.
- No External Libraries: The project uses only vanilla HTML, CSS, and JavaScript without relying on any external libraries or frameworks.
- Graceful Draw Handling: When the game ends in a draw, the "Draw Game!" message is displayed, and the boxes change color to indicate the draw.
- Accessibility: The game has accessible features, such as color contrast and text alternatives for screen readers.
- Consistency: The game maintains a consistent UI design and user experience.
- Scalability: The code structure allows for easy scaling and potential future enhancements, such as adding AI opponents or different board sizes.
- Open the
index.html
file in your web browser. - The game starts with Player 1 (X) making the first move.
- Players take turns to click on an empty cell in the grid to place their respective symbols (X or O).
- The first player to get three of their symbols in a row (horizontally, vertically, or diagonally) wins the game.
- If all the cells are filled and no player has three symbols in a row, the game ends in a draw.
game_logic.js
: This JavaScript file contains the game logic, event handlers, and functions for checking the winner and draw conditions.index.html
: The main HTML file containing the game board and user interface elements.style.css
: The CSS file containing styles for the game board and user interface.
- HTML
- CSS
- JavaScript
Check out the live demo here.
Contributions to this project are welcome! If you have any improvements or new features to add, feel free to submit a pull request.
This project is licensed under the MIT License.
The project was created by Melvin K J.
Thanks to the creators of the Finger Paint font used in this project.