Skip to content

About

Tic-Tac-Toe / A simple interactive Tic-Tac-Toe game built with HTML, CSS, and JavaScript, featuring a clean interface and two-player gameplay.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ Tic-Tac-Toe

A simple and interactive Tic-Tac-Toe web game built using HTML, CSS, and JavaScript.

The project provides a clean browser-based gaming experience while demonstrating fundamental concepts of frontend web development, JavaScript game logic, DOM manipulation, and user interaction.

๐Ÿ”— Repository: https://github.com/Atibayounus/TIC-TAC-TOE.git


๐Ÿ“Œ About the Project

Tic-Tac-Toe is a classic two-player game played on a 3 ร— 3 grid.

Players take turns placing their symbols:

  • โŒ Player X
  • โญ• Player O

The objective is to get three matching symbols in a row, column, or diagonal before the opponent.

This project was built to practice HTML structure, CSS styling, and JavaScript logic while creating a functional interactive web application.


โœจ Features

  • ๐ŸŽฎ Two-player gameplay
  • โŒ X and O turns
  • ๐Ÿงฉ Interactive 3 ร— 3 game board
  • ๐Ÿ† Automatic winner detection
  • ๐Ÿค Draw detection
  • ๐Ÿ”„ Restart / New Game functionality
  • โšก Instant game updates
  • ๐Ÿ–ฑ๏ธ Click-based interaction
  • ๐Ÿ“ฑ Clean and responsive interface
  • ๐ŸŒ Runs directly in the browser

๐Ÿ“ธ Screenshots

๐Ÿ  Game Interface

Game Interface

๐Ÿ† winner

Gameplay

๐ŸŽฎDraw Condition

Game Result

๐Ÿ› ๏ธ Technologies Used

HTML5

Used to create the structure of the game:

  • Game board
  • Player information
  • Buttons
  • Game status

CSS3

Used to design the interface:

  • Game board layout
  • Styling
  • Spacing
  • Typography
  • Buttons
  • Responsive design
  • Hover effects

JavaScript

Used to implement the game functionality:

  • Player turns
  • Click events
  • Game state
  • Winner detection
  • Draw detection
  • Reset functionality
  • DOM manipulation

๐Ÿง  Core Concepts

๐ŸŒ HTML

HTML provides the basic structure of the application.

<div class="game-board">
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell"></div>
</div>

๐ŸŽจ CSS

CSS controls the visual appearance and layout of the game.

The board can be created using CSS Grid:

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
}

โšก JavaScript

JavaScript handles the actual game logic.

For example, click events can be used to detect when a player selects a cell:

cell.addEventListener("click", handleClick);

The program then updates the board and checks whether a player has won.


๐Ÿ† Winning Logic

There are 8 possible winning combinations in Tic-Tac-Toe:

Rows

X | X | X
---------
  |   |
---------
  |   |

Columns

X |   |
X |   |
X |   |

Diagonals

X |   |
  | X |
  |   | X

JavaScript checks these combinations after each move to determine the winner.


๐ŸŽฎ How to Play

  1. Open the game in your browser.
  2. Player X starts the game.
  3. Click an empty cell.
  4. Player O takes the next turn.
  5. Continue taking turns.
  6. Get three matching symbols in a row, column, or diagonal to win.
  7. If all cells are filled without a winner, the game ends in a draw.
  8. Use the restart button to play again.

๐Ÿ“‚ Project Structure

TIC-TAC-TOE/
โ”‚
โ”œโ”€โ”€ index.html
โ”œโ”€โ”€ style.css
โ”œโ”€โ”€ script.js
โ”‚
โ””โ”€โ”€ README.md

๐Ÿš€ Getting Started

No installation or external dependencies are required.

1. Clone the Repository

git clone https://github.com/Atibayounus/TIC-TAC-TOE.git

2. Open the Project

cd TIC-TAC-TOE

3. Run the Game

Simply open:

index.html

in any modern web browser.

You can also use VS Code Live Server for development.


๐Ÿ”„ Game Flow

Start Game
    โ†“
Player X Turn
    โ†“
Select Cell
    โ†“
Update Board
    โ†“
Check Winner
    โ†“
Check Draw
    โ†“
Player O Turn
    โ†“
Select Cell
    โ†“
Update Board
    โ†“
Check Winner
    โ†“
Check Draw
    โ†“
Game Over / Continue

๐Ÿ“ฑ Responsive Design

The interface is designed to work across different screen sizes, including:

  • ๐Ÿ’ป Desktop
  • ๐Ÿ’ป Laptop
  • ๐Ÿ“ฑ Mobile
  • ๐Ÿ“ฒ Tablet

CSS media queries can be used to adjust the layout for smaller screens.


๐ŸŽ“ Learning Outcomes

Building this project helped me practice:

  • HTML5 structure
  • CSS3 styling
  • CSS Grid
  • JavaScript fundamentals
  • DOM manipulation
  • Event listeners
  • Arrays
  • Functions
  • Conditional statements
  • Game state management
  • Winner detection
  • User interaction
  • Debugging

๐Ÿ”ฎ Future Improvements

Possible improvements include:

  • ๐Ÿค– Add a computer/AI opponent
  • ๐ŸŽš๏ธ Add difficulty levels
  • ๐Ÿ† Add score tracking
  • ๐Ÿ‘ค Add player names
  • ๐Ÿ”Š Add sound effects
  • โœจ Add animations
  • ๐ŸŒ™ Add theme switching
  • ๐Ÿ“Š Add match statistics
  • ๐Ÿ’พ Store scores using Local Storage

๐Ÿ‘จโ€๐Ÿ’ป Author

Atiba Dar

๐ŸŽ“ Computer Science Student ๐Ÿซ University of Gujrat, Pakistan ๐Ÿ’ป Frontend Developer & Programming Learner

GitHub

๐Ÿ”— @Atibayounus


โญ Support

If you like this project, consider giving the repository a โญ on GitHub.


Built with HTML, CSS & JavaScript โ€” one move at a time. ๐ŸŽฎ๐Ÿ’ป

About

Tic-Tac-Toe / A simple interactive Tic-Tac-Toe game built with HTML, CSS, and JavaScript, featuring a clean interface and two-player gameplay.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages