plibither8

2048.cpp

? Fully featured terminal version of the game "2048" written in C++
Under MIT License
By plibither8

game cpp11 cpp 2048 2048-game

2048.cpp



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



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




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:
    sh
    git clone https://github.com/plibither8/2048.cpp

  2. Enter the project directory:
    sh
    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
    sh
    ctest -S setup.cmake


  2. Install the program (optional)
    sh
    cmake --install build




  3. Run the program and play the game! :tada:
    sh
    2048 # run `build/2048` if game is not installed





OR

Building with Meson


  1. Generate build configuration
    sh
    meson build

  2. Build the executable and run tests
    sh
    meson test -C build


  3. Install the program (optional)
    sh
    meson configure build --prefix=$HOME/.local
    meson install -C build




  4. Run the program and play the game! :tada:
    sh
    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.



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


To-Do

License

Copyright (c) Mihir Chaturvedi. All rights reserved.


Licensed under the MIT License.