Terminal version of the game "2048" written in C++.
? Featured on GitHub's Twitter and Facebook pages! ?
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.
g++
, clang++
, pgc++
, icpc
, etc.)git clone https://github.com/plibither8/2048.cpp
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.
ctest -S setup.cmake
cmake --install build
2048 # run `build/2048` if game is not installed
OR
meson build
meson test -C build
meson configure build --prefix=$HOME/.local
meson install -C build
2048 # run `build/2048` if game is not installed
First of all, thank you for contributing ?! A few things to note:
If you have found a bug, or have a feature that you'd like implemented, raise an issue.
If you have proposed a pull request, make sure that you run clang-format
on the source code (both, .cpp
and .hpp
) files if you've made changes there.
In your local repository, run git update-index --skip-worktree ./data/*.txt
to ensure that changes to the data files are not tracked by git, and thus are not staged.
I deeply appreciate the help of the following people:
cstdlib rand
to C++ random int generator.CMakeLists.txt
file.1
to be printed.clang-format
.Game
class constructor.CMakeLists.txt
file and made Color
enum to a scoped enum.const
s.[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
andcolumn
indexing starts at 0.
┌──────┬──────┬──────┬──────┐
│ │ │ │ │
├──────┼──────┼──────┼──────┤
│ │ │ │ │
├──────┼──────┼──────┼──────┤
│ @ │ │ │ │
├──────┼──────┼──────┼──────┤
│ │ │ │ │
└──────┴──────┴──────┴──────┘
Copyright (c) Mihir Chaturvedi. All rights reserved.
Licensed under the MIT License.