Here is a programming project in C that I've carried out during the second year of my bachelor's degree for the "Development techniques" class. It is a puzzle game named Sokoban.
You'll find here the base files for the project concerning the game of Sokoban. The instructions are to be found at this address TP Sokoban
Sokoban is a puzzle video game invented in Japan. The player has to move the crates to the target spots. The player can move in the four directions and push (but not pull) a single crate at a time. Once all the crates are put away (it's sometimes a real headache), the level is complete and the player moves on to the next level. (Wikipedia article)
The online documentation for this project is hosted by Github Pages and is found at this address https://greengageplum.github.io/Sokoban/. It is automatically built during each release using Github Actions. Attention, the documentation is in French since I carried out this project during my bachelor's in France.
I was inspired by these git repos:
Efe ERKEN
Year: 2nd year 3rd semester Autumn 2022
Groups: TD2-TP4
I used "GNU gcc" et "Apple clang" as compilers. I used gcc
while I was working on the machines of the faculty and while I was working from home, I used clang
.
I paid attention to test my program on the machines of the faculty to check for errors before turning in on Moodle.
Right below are the versions of the compilers that I used.
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
gcc-12 (Homebrew GCC 12.2.0) 12.2.0
Apple clang version 14.0.0 (clang-1400.0.29.102)
Apple clang version 14.0.0 (clang-1400.0.29.202)
First, install the dependencies with your package manager (apt, dnf, apk, brew, etc.): gcc
(GNU C toolchain), make
, libsdl2
, libsdl2-dev
(for the compilation), libncurses
, libncurses-dev
(for the compilation).
Then download the project on your machine with one of the following commands:
git clone https://github.com/GreengagePlum/Sokoban.git
or
git clone [email protected]:GreengagePlum/Sokoban.git
Once that's done, go to the project directory and compile.
cd sokoban/
make
From now on you can execute the game so long as you're in its directory.
./sokoban --console
or
./sokoban --sdl2
First, install the dependencies with your package manager (apt, dnf, apk, brew, etc.): doxygen
, graphviz
.
To generate the documentation for your copy of the program, use the following command and take a look at the file doc/public/index.html
in your favorite web browser.
make doc
Or else, you could see the online documentation for the latest version.
To archive the project with all the necessary files to compile and generate the documentation in a tar.gz
format for redistribution, use the following command:
make archive
To clean the project directory to start from zero there are multiple useful commands.
Remove all compilation files (*.o
, *.d
, final executable). This is to be done especially if you're changing the options of gcc
(like adding -g
for debugging) or if you're switching to the test executable with the command make test
.
make clean
Remove the documentation and its directories
make cleandoc
Remove the archive
make cleanarchive
This is a command that groups together all that came before. It removes all the compilation, documentation and archive files and directories.
make cleanall
To have a developer environment for this projet to develop locally or to make contributions, follow the past instructions to get the source code and install the dependencies.
Ensuite, vous pouvez si vous choisissez, configurer les tests pour pouvoir les effectuer en local et aussi pour avoir un avis sur comment serait le resultat des tests sur le serveur effectué en CI/CD.
Next, you can if you wish, configure the tests to be able to run them locally and also, to have an idea on how the results of the tests on the server done by CI/CD would be.
To do this, install python
(version 3) and pre-commit
.
Once you have python
,
python -m venv .venv # I advise you to create a virtual environment with your favorite method
source .venv/bin/activate # Activate the virtual environment
pip install --upgrade pip # Upgrade pip
pip install pre-commit # Install pre-commit
pre-commit install -t pre-commit -t pre-push # Configure the git hooks
pre-commit run -a --hook-stage pre-push # Run all the tests for the first time
Use the 'h', 'j', 'k', 'l' keys to move (or you can also use the arrow keys if you're in --sdl2
mode).
Press 'q' to quit the game.
Poussez les boites sur les multiples cibles dans le niveau. Une fois toutes les cibles sont couvertes vous gagnez. Vous ne pouvez pas tirer les boites et vous ne pouvez pas pousser deux ou plus de boites en même temps.
Push the crates over the multiple targets in the level. Once all the targets are covered, you win. You cannot pull the crates and neither can you push two or more crates at the same time.
This project is under the "GPLv3 or later" license.
The git repository of this project follows a clear and determined structure put forth by Vincent Driessen in his post "A successful Git branching model".
So don't be surprised by the fact that the main branch
has few commits. All the development is happening on
the develop branch
. Before each version, everything is prepared and guaranteed functional to be merged
into main branch
which only has stable and complete versions.
These are the meanings of the emojis used in the git commit messages. See gitmoji also.
Emoji | Meaning |
---|---|
✨ NEW | New file or feature |
🔧 UPDATE | Update of a part of the program |
🔨 CONFIG | Changes in config files like makefile and doxyfile |
♻️ REFACTOR | Rewrite of a part of the program |
🐛 BUGFIX | A bug fix |
🔥 DELETION | Removal of a file or a feature |
📝 DOC | Changes in the documentation |
🎉 EPOCH | The beginning of the project |
🚀 RELEASE | A new version of the program |