Cross-platform, over-engineered XTetris written in C
- Single-player game mode
- Two-players game mode
- Player vs. AI game mode (AI algorithm is still really basic)
- Piece control with keyboard and mouse
- 2D CLI graphics abstraction
- Audio output support
- KB_RIGHT - Confirm
- KB_LEFT - Exit / Back
- KB_UP, KB_DOWN - Menu navigation
- KB_LEFT, KB_RIGHT - Rotate the tetromino
- KB_UP, KB_DOWN - Change tetromino
- MOUSE_X - Position the tetromino in the x-axis
- MOUSE_LEFT - Drop the current tetromino in the board
Requirements:
- cmake
- make
- pkg-config (macOS/Linux only)
Building the program is done by running the following commands:
git clone --recursive https://github.com/sonodima/nxtetris
cd nxtetris
mkdir -p build/release
cd build/release
cmake ../.. -DCMAKE_BUILD_TYPE=Release
make
The output executable will be named nxtetris
and will be placed in build/release
.
NOTE: The binary needs to be shipped with the resources
folder (which is copied to the build directory at
compile time) in order to work properly. (without it the audio won't play)
Due to ncurses limitations, on Windows MinGW is required to compile the program.
You can use the following command to generate the Makefile for MinGW:
cmake ../.. -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles"
- ncurses: terminal control library, enabling the construction of text user interface (TUI) applications.
- portaudio: cross-platform audio I/O library.
- libsndfile: audio file I/O library.
All the libraries are managed by vcpkg and are automatically obtained during the build process.
NOTE: The first build will take a while since all the libraries need to be downloaded and built.