NXTetris
NXTetris

NXTetris 🕹️



‍Cross-platform, over-engineered XTetris written in C

Features

  • [x] Single-player game mode
  • [x] Two-players game mode
  • [x] Player vs. AI game mode _(AI algorithm is still really basic)_
  • [x] Piece control with keyboard and mouse
  • [x] 2D CLI graphics abstraction
  • [x] Audio output support

Controls

Menu(s)

  • KB_RIGHT - Confirm
  • KB_LEFT - Exit / Back
  • KB_UP, KB_DOWN - Menu navigation

Game

  • 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

Build

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)_

Windows Compilation

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"

Libraries

  • 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.