Welcome to the Connect 4 game, a classic two-player strategy game built with React. This project was bootstrapped with Create React App and is deployed on Vercel.
- Interactive Gameplay: A fully functional Connect 4 board where two players can alternate turns.
- Dynamic Rendering: React's component-based architecture ensures smooth updates and efficient re-renders.
- Responsive Design: The game is fully responsive, providing an optimal experience across devices.
- Deployment: Deployed on Vercel for quick and reliable access.
Check out the live version of the game here: Connect 4 Game
To run this project locally, follow these steps:
- Clone the repository:
git clone https://github.com/your-username/connect-4.git
- Navigate to the project directory:
cd connect-4
- Install the dependencies:
npm install
- Start the development server:
npm start
The application will start on http://localhost:3000
.
- Open the game in your browser.
- Players take turns dropping discs into one of the seven columns.
- The first player to connect four of their discs vertically, horizontally, or diagonally wins.
- Reset the game at any time by clicking the "Reset" button.
- React: A JavaScript library for building user interfaces.
- Create React App: A boilerplate tool that allows you to set up a React project with no build configuration.
- JavaScript (ES6+): Leveraging modern JavaScript features.
- CSS3: For responsive and modern design.
- Vercel: For continuous deployment and hosting.
The project follows a component-based architecture, ensuring separation of concerns and reusability.
- Board: Handles the rendering of the Connect 4 grid and manages the game state.
- Cell: Represents each individual cell on the board.
- Game Logic: Encapsulated within a custom hook, ensuring that the core logic is decoupled from the presentation layer.
- Status: Displays the current status of the game (whose turn it is or if someone has won).
- The game state is managed using React's
useState
anduseEffect
hooks. - The board is represented as a 2D array, and each move updates the state.
The game logic is encapsulated in a custom React hook, useConnect4
, which includes:
- Move Validation: Ensures that discs are only placed in valid positions.
- Win Detection: Checks for four consecutive discs horizontally, vertically, or diagonally.
- Draw Detection: Determines if the board is full without any winner.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes and commit them (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
This README provides a comprehensive technical overview of the Connect 4 project, making it easy for developers to understand the structure, usage, and deployment process.