https://github.com/omid2831/tic-tac-toe
A fun and engaging version of the classic Tic Tac Toe game, designed for two players to compete
https://github.com/omid2831/tic-tac-toe
game java swing-application swing-gui
Last synced: about 2 months ago
JSON representation
A fun and engaging version of the classic Tic Tac Toe game, designed for two players to compete
- Host: GitHub
- URL: https://github.com/omid2831/tic-tac-toe
- Owner: Omid2831
- Created: 2024-01-14T20:54:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-23T12:54:52.000Z (about 2 months ago)
- Last Synced: 2025-03-23T13:37:59.463Z (about 2 months ago)
- Topics: game, java, swing-application, swing-gui
- Language: Java
- Homepage:
- Size: 4.92 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tic Tac Toe Game 🎮
This is a **native Java** implementation of the classic **Tic Tac Toe** game. The game features a graphical user interface (GUI) built using `Swing`, offering smooth gameplay with automatic win/draw detection.
---
## 🖼️ Demo
### Gameplay Example:[](capture/Demo.mp4)
> *Click the image above to watch the gameplay video.*
## ✨ Features- **Two-player gameplay**: Play with friends using classic Tic Tac Toe rules.
- **GUI built with Swing**: Intuitive interface for quick interactions.
- **Dynamic game logic**: The game checks for winners and draws automatically.
---## 🚀 How to Run
### Prerequisites
- [**Java Development Kit (JDK)**](https://www.oracle.com/java/technologies/downloads/) installed (version 8 or higher)
- [**Git**](https://git-scm.com/) installed### Clone the Repository
1. Open your terminal and clone the repository:
```bash
git clone https://github.com/Omid2831/Tic-tac-toe.git
```
2. Navigate into the project directory:
```bash
cd Tic-tac-toe
```
### Compile and Run
1. Compile the source files and place the compiled classes in the `bin` directory:
``` bash
javac -d bin *.java
```
3. Run the program:
```bash
java -cp bin main
```
(Please make sure main.java is your program's entry point.)
---
### 🛠️ File Structure
📂 Tic-tac-toe
├── main.java # Main entry point of the application
├── TikTakToe.java # Game logic and GUI implementation
├── main.class # Compiled bytecode for main
├── TikTakToe.class # Compiled bytecode for game logic
├── 📂 capture
│ ├── Demo.mp4 # Gameplay video
│ └── pic.png # Screenshot of the game
---
## 🧑💻 How It WorksThe game operates as follows:
1. **Game Setup**
- The game is played on a 3x3 grid.
- Two players take turns to mark their respective symbols (`X` or `O`).2. **Gameplay**
- The GUI dynamically updates to reflect each player's move.
- Players alternate turns until a win, draw, or loss condition is met.3. **Game Result Detection**
- The program checks for the following outcomes:
- **Wins**:
- Three aligned marks (horizontally, vertically, or diagonally).
- **Loss**:
- The other player achieves three aligned marks.
- **Draws**:
- The board is full, and no player has achieved three aligned marks.4. **Feedback**
- The GUI highlights:
- Winning cells if a player wins.
- A message indicates the game result (win, loss, or draw).
---