Skip to content
๐ŸŽฎ It is a two-player connection game in which the players first choose a color and then take turns dropping one colored disc from the top into a seven-column, six-row vertically suspended grid. The pieces fall straight down, occupying the lowest available space within the column, user wins by forming row of four of same color
Python Shell
Branch: master
Clone or download

Latest commit

Fetching latest commitโ€ฆ
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
images
sounds
.gitignore
CODE_OF_CONDUCT.md
LICENSE
README.md
_config.yml
assets.py
config.py
connect_game.py
events.py
game.py
game_board.py
game_data.py
game_renderer.py
requirements.txt
restart.sh

README.md

Open Issues Forks Stars Maintained Made with Python Open Source Love Built with Love Follow Me GitHub followers Slack

๐Ÿ“’ Index

๐Ÿ”ฐ About

Connect Four is a two-player connection game in which the players first choose a color and then take turns dropping one colored disc from the top into a seven-column, six-row vertically suspended grid. The pieces fall straight down, occupying the lowest available space within the column. The objective of the game is to be the first to form a horizontal, vertical, or diagonal line of four of one's own discs.

๐Ÿ“„ Features

  • 2 player interactive game
  • Supports undo operation
  • Supports interactive game sounds
  • Ability to play with computer AI (in development phase)
  • Multiplayer on local network using sockets (in development phase)
  • Ability to customize game theme (in development phase)
  • Cross platform Linux, Windows, Mac (in development phase)

โšก๏ธ Usage

To use this project.

๐Ÿ”Œ Installation

  • Install dependencies & export environment variables.
$ sudo -H pip3 install -r requirements.txt

๐Ÿ“ฆ Commands

  • Start project using
$ python3 game.py

๐Ÿ“ File Structure

  • Add a file structure here with the basic details about files, below is current file structure.
.
โ”œโ”€โ”€ assets.py
โ”œโ”€โ”€ CODE_OF_CONDUCT.md
โ”œโ”€โ”€ config.py
โ”œโ”€โ”€ _config.yml
โ”œโ”€โ”€ connect_game.py
โ”œโ”€โ”€ events.py
โ”œโ”€โ”€ game_board.py
โ”œโ”€โ”€ game_data.py
โ”œโ”€โ”€ game.py
โ”œโ”€โ”€ game_renderer.py
โ”œโ”€โ”€ images
โ”‚ย ย  โ”œโ”€โ”€ blackball91px.png
โ”‚ย ย  โ”œโ”€โ”€ game.svg
โ”‚ย ย  โ”œโ”€โ”€ logo
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ c4.gif
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ connect4.gif
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ connect4.png
โ”‚ย ย  โ”œโ”€โ”€ redball90px.png
โ”‚ย ย  โ”œโ”€โ”€ screenshots
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ 1.png
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ 2.gif
โ”‚ย ย  โ””โ”€โ”€ yellowball90px.png
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ restart.sh
โ””โ”€โ”€ sounds
    โ”œโ”€โ”€ disc_drop_1.wav
    โ”œโ”€โ”€ disc_drop_2.wav
    โ””โ”€โ”€ event.ogg

4 directories, 26 files
No File Name Details
1. assets.py used for loading sound and image files in python.
2. config.py contains game's configuration settings.
3. connect_game.py Contains the ConnectGame class which holds the logic for the whole game.
4. events.py Contains classes used to define and hold event data.
5. game_board.py Contains the GameBoard data structure and methods which operate on it.
6. game_data.py Contains the GameData class, which contains all of the data in the game.
7. game_renderer.py Holds the GameRenderer class, which renders the game state using sound and graphics.
8. game.py contains connect four game logic.
9. images/ contains image resources used in the game.
10. images/logo/ contains logo used in the README.
11. images/screenshots/ contains game screenshots.
12. LICENSE this project uses MIT License.
13. requirements.txt contains all the dependencies used in the game.
14. restart.sh bash script to relaunch the game once it is finished.
15. sounds/ contains sound resources used in the game.
16. CODE_OF_CONDUCT.md tells about our responsibilities as a team
  • Dependency Graph

โ—๏ธ Guideline

  • Code Style

black

In order to maintain the code style consistency across entire project I use a code formatter. I kindly suggest you to do the same whenever you push commits to this project.

The python code formatter I chose is called Black. It is a great tool and it can be installed quickly by running

sudo -H pip3 install black

or

python3.6 -m pip install black

It requires Python 3.6.0+ to run.

  • Usage
black {source_file_or_directory}

For more details and available options, please check their psf/black.

isort

I also use isort, it is a Python utility / library to sort imports alphabetically, and automatically separated into sections. It provides a command line utility which can be installed using.

sudo -H pip3 install isort
  • Usage
isort {source_file}.py

For more details and available options, please check their timothycrosley/isort.

  • Close Issues

Close issues using keywords: how to ?

๐ŸŒธ Community

๐Ÿ”ฅ Contribution

Your contributions are always welcome and appreciated. Following are the things you can do to contribute to this project.

  1. Report a bug
    If you think you have encountered a new issue, and I should know about it, feel free to report it here and I will take care of it.

  2. Create a pull request
    It can't get better then this, your pull request will be appreciated by the community. You can get started by picking up any open issues from here and make a pull request.

If you are new to open-source, make sure to check read more about it here and learn more about creating a pull request here.

๐ŸŒต Branches

  • No other permanent branches should be created in the main repository, you can create feature branches but they should get merged with the master.

๐Ÿ“„ Resources

  • PyGame Documentation : Pygame is a cross-platform set of Python modules designed for writing video games. It includes computer graphics and sound libraries designed to be used with the Python programming language.

๐Ÿ“ท Gallery

Start Game Window

Game Play

Game Play GIF

Restart or Quit as the Game ends.

๐ŸŒŸ Credit/Acknowledgment

Contributors

๐Ÿ”’ License

License

โœจ Hall Of Fame

You canโ€™t perform that action at this time.