Home

Awesome

2048.cpp

Actions Status Codacy Badge Language grade: C/C++ Made with Love in India Run on Repl.it

Terminal version of the game "2048" written in C++.

:tada: Featured on GitHub's Twitter and Facebook pages! :tada:

<p align="center"> <img align="center" alt="2048 in action!" src="assets/demo.gif"></img> </p>

Setup

The game and code is made to run natively on the GNU/Linux and MacOS platforms, but cross-platform compatibility for Windows has been added too.

Requirements

Installation

  1. Open your terminal in your preferred directory and clone this project:
git clone https://github.com/plibither8/2048.cpp
  1. Enter the project directory:
cd 2048.cpp

For both CMake and Meson, the default C++ compiler on your system will be used. If you wish to manually select a C++ compiler, optionally add CXX=clang++ cmake or CXX=clang++ meson etc.

Building with CMake

  1. Build the executable and run tests
ctest -S setup.cmake
  1. Install the program (optional)
cmake --install build
  1. Run the program and play the game! :tada:
2048    # run `build/2048` if game is not installed
<p align="center"> <b>OR</b> </p>

Building with Meson

  1. Generate build configuration
meson build
  1. Build the executable and run tests
meson test -C build
  1. Install the program (optional)
meson configure build --prefix=$HOME/.local
meson install -C build
  1. Run the program and play the game! :tada:
2048    # run `build/2048` if game is not installed

Contributing

First of all, thank you for contributing :smile:! A few things to note:

Thanks

I deeply appreciate the help of the following people:

Maintainers

Notes

[GameBoard].getTile(2,0) refers to the 0th tile (or column) in 2nd row as in this case, x = 0 and y = 2. The specific tile is denoted the by '@' symbol in the following gameboard:

Note: row and column indexing starts at 0.

┌──────┬──────┬──────┬──────┐
│      │      │      │      │
├──────┼──────┼──────┼──────┤
│      │      │      │      │
├──────┼──────┼──────┼──────┤
│   @  │      │      │      │
├──────┼──────┼──────┼──────┤
│      │      │      │      │
└──────┴──────┴──────┴──────┘

To-Do


License

Copyright (c) Mihir Chaturvedi. All rights reserved.

Licensed under the MIT License.