Skip to content

The Tic Tac Toe game allows two players to compete against each other on a 3x3 grid. Players take turns placing their respective symbols (X or O) on the board. The game continues until one player gets three of their symbols in a row horizontally, vertically, or diagonally, or all squares are filled resulting in a tie.

Notifications You must be signed in to change notification settings

Vishrut99/Tic-Toc-Toe-game-in-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Tic-Tac-Toe Game in Java

A classic Tic-Tac-Toe game implemented in Java with a graphical user interface using Swing. This interactive game allows two players to compete against each other on a 3x3 grid in a visually appealing desktop application.

๐ŸŽฎ Game Overview

The Tic-Tac-Toe game allows two players to compete against each other on a 3x3 grid. Players take turns placing their respective symbols (X or O) on the board. The game continues until one player gets three of their symbols in a row horizontally, vertically, or diagonally, or all squares are filled resulting in a tie.

๐Ÿš€ Key Features

  • Graphical User Interface: Visually appealing window with a 3x3 game board and text panel
  • Two-Player Gameplay: Alternates between Player X and Player O for each turn
  • Win Detection: Automatically checks for winning conditions horizontally, vertically, and diagonally
  • Tie Condition: Detects when all squares are filled without a winner
  • Visual Feedback: Changes color of winning tiles and displays game results
  • Current Player Display: Shows whose turn it is during gameplay
  • Interactive Board: Click-based tile selection system

๐Ÿ› ๏ธ Technologies Used

  • Java: Core game logic and application structure
  • Swing: Graphical user interface components (buttons, labels, panels)
  • AWT (Abstract Window Toolkit): Color and font styling
  • Event Handling: User interaction detection for tile clicks

๐ŸŽฏ Game Rules

  1. The game is played on a 3x3 grid
  2. Player X always goes first
  3. Players take turns placing their symbol (X or O) in empty squares
  4. The first player to get 3 of their symbols in a row (horizontally, vertically, or diagonally) wins
  5. If all 9 squares are filled without a winner, the game ends in a tie

๐Ÿƒโ€โ™‚๏ธ How to Run

  1. Prerequisites: Ensure you have Java Development Kit (JDK) installed on your system
  2. Clone the repository:
    git clone https://github.com/Vishrut99/Tic-Toc-Toe-game-in-java.git
  3. Navigate to the project directory:
    cd Tic-Toc-Toe-game-in-java
  4. Compile the Java files:
    javac *.java
  5. Run the game:
    java TicTacToe

๐ŸŽจ User Interface

The game features a clean and intuitive interface with:

  • A 3x3 grid of clickable buttons representing the game board
  • A text panel at the top showing current player turn and game results
  • Color-coded feedback for winning combinations
  • Responsive button interactions

๐Ÿ”ง Technical Implementation

The game utilizes object-oriented programming principles with:

  • Event-driven architecture for user interactions
  • Efficient win condition checking algorithms
  • Clean separation of game logic and UI components
  • Proper state management for game flow

๐Ÿ† Win Conditions

The game checks for wins in all possible combinations:

  • Horizontal: Three symbols in any row
  • Vertical: Three symbols in any column
  • Diagonal: Three symbols in either diagonal direction

๐ŸŽญ Visual Feedback

  • Winning tiles are highlighted with distinctive colors
  • Current player is clearly displayed
  • Tie games are prominently announced
  • Smooth transitions between game states

๐Ÿ”„ Future Enhancements

Potential improvements for future versions:

  • Single-player mode with AI opponent
  • Score tracking across multiple games
  • Different difficulty levels
  • Sound effects and animations
  • Customizable player names
  • Game history and statistics

๐Ÿค Contributing

Feel free to fork this project and submit pull requests for any improvements or bug fixes. All contributions are welcome!

๐Ÿ“ License

This project is open source and available under the MIT License.

๐Ÿ“ง Contact

Vishrut Lathiya
Email: vishrutpatel50@gmail.com


Enjoy playing this classic game! ๐ŸŽฏ

About

The Tic Tac Toe game allows two players to compete against each other on a 3x3 grid. Players take turns placing their respective symbols (X or O) on the board. The game continues until one player gets three of their symbols in a row horizontally, vertically, or diagonally, or all squares are filled resulting in a tie.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages