This is a Tetris terminal game based on the C language and the ncurses library, which I implemented in my spare time.
This project uses the ncurses terminal graphics library for console drawing. So, the first thing you need to do is ensuring whether this library has been installed on your system before compiling. If you use Arch Linux, you can run the following command.
sudo pacman -S ncursesIf you use other Linux distributions like Ubuntu, Fedora and so on, you can obtain it through the corresponding package manager.
After preparing the dependencies, you can open a terminal in the project root directory, and run the following command.
makeThen you will find the compiled binary executable file in the bin directory, switch to the bin directory to run the tetris game.
cd ./bin./tetris| Function | Corresponding keyboard keys |
|---|---|
| Move left | Left arrow key / A / a |
| Move right | Right arrow key / D / d |
| Rotate clockwise | Up arrow key / W / w |
| Hard landing | Down arrow key / S / s |
| Temporary storage/Swap | Space bar |
| Pause game | P / p |
| Exit game | Q / q |
| Restart game after it ends | R / r |
Your goal is to clear rows to score points. As you level up, the blocks fall faster, so challenge yourself!
I will continue to optimize this game, and in the future I hope to add more features, such as save functionality, online multiplayer, etc.