An open API service indexing awesome lists of open source software.

https://github.com/sonodima/nxtetris

Cross-platform, over-engineered XTetris built in ANSI-C
https://github.com/sonodima/nxtetris

cross-platform game game-development ncurses tui xtetris

Last synced: about 2 months ago
JSON representation

Cross-platform, over-engineered XTetris built in ANSI-C

Awesome Lists containing this project

README

        

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:

```bash
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:

```bash
cmake ../.. -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles"
```

## Libraries

- [ncurses:](https://invisible-island.net/ncurses) terminal control library, enabling the construction of text user
interface (TUI) applications.
- [portaudio:](http://www.portaudio.com/) cross-platform audio I/O library.
- [libsndfile:](http://www.mega-nerd.com/libsndfile/) audio file I/O library.

All the libraries are managed by [vcpkg](https://vcpkg.io/) 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.