This Connect Four game allows two players to compete against each other in a classic game of Connect Four. Players take turns placing pieces in a grid, aiming to connect four pieces horizontally, vertically, or diagonally. The game features a simple user interface with options to start a new game, reset the board, and display a winner overlay when someone wins.
Click here to view a demo of my game
- Setup Game Environment
- Create a 7x6 grid for the game board.
- Implement the initial setup with start and reset buttons.
- Game Functionality
- Allow players to place pieces in the grid.
- Switch turns between players.
- Detect winning conditions (horizontal, vertical, diagonal).
- Display the winner and provide options for a new game or reset.
- User Interface
- Design a responsive layout for different screen sizes.
- Animate piece placement and winning conditions.
- Provide visual feedback for player actions and game status.
- Additional Features
Implement media queries for responsiveness. Add sound effects for piece placement and winning. Optionally, implement a computer vs. player mode.
- Game Initialization
- Start the game with a start button.
- Dynamically generate the game board.
- Hide the start button after the game starts.
- Piece Placement
- Click on a column to place a piece.
- Pieces will slide down and grow in size to their final position.
- Winning Conditions
- Check for horizontal, vertical, and diagonal connections of four.
- Display a winner overlay with the winning player's color.
- Game Reset
- Provide a reset button to restart the game.
- Ask for confirmation before resetting the game if it is not empty.
- Show a confirmation prompt before resetting.
- Responsive Design
- Ensure the game is responsive across various devices.
- Adjust game board size and layout based on screen width.
- Animations
- Animate pieces as they are placed on the board.
- Use CSS animations for piece placement and winning announcements.
- User Feedback
- Display messages for invalid moves (e.g., full column).
- Highlight the current player's turn.
- Sound Effects (Optional)
- Add sound effects for piece placement and game events.
- Computer vs. Player Mode (Optional)
- Implement an AI to play against a human player.
- Clone the Repository
bash Copy code git clone <repository-url> cd <repository-directory>
- Open the Project
- Open index.html in a web browser to start playing.
- Customize and Extend
- Modify styles in styles.scss for custom looks.
- Add or change functionality in the game.ts file.
- CSS/SCSS: styles.scss
- JavaScript/TypeScript: game.ts
Feel free to submit pull requests or open issues for any bugs or feature requests. Contributions are welcome!