/2048.cpp

🎮 Terminal version of the game "2048" written in C++ 11

Primary LanguageC++MIT LicenseMIT

2048.cpp

Build Status Build status Made with Love in India

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

🎉 Featured on GitHub's Twitter and Facebook pages! 🎉

Demo of usage

To-Do

  • Add start menu [19/04/2018]
  • Save highscore / score [21/04/2018]
  • Save a game state and play from a saved game state (Abandoned indefinitely)
  • AI (Abandoned indefinitely)

Setup

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

Requirements

  • C++ compiler (e.g. g++, clang++, etc.)
  • Linux, MacOS OR Windows with a working terminal (Cygwin, Windows Subsystem for Linux or Git bash is recommended for Windows)

Instructions

  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
  1. Create a build folder (Optional):
$ mkdir build
  1. Compile the 2048.cpp file and create an output using the Makefile:
$ make
  1. Run the program and play the game!
$ ./build/2048.out

Notes

  • Game board array is defined as board[y][x]
  • Game board will follow the following structure:
'x' => x-axis OR the horizontal line OR columns
'y' => y-axis OR the vertical line OR rows

For example (zero-indexed)

board[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:

+------+------+------+------+
|      |      |      |      |
+------+------+------+------+
|      |      |      |      |
+------+------+------+------+
|   @  |      |      |      |
+------+------+------+------+
|      |      |      |      |
+------+------+------+------+

License

Copyright (c) Mihir Chaturvedi. All rights reserved.

Licensed under the MIT License.