2048.cpp – Play 2048 in directly your terminal
source link: https://www.tuicool.com/articles/hit/aUzuYf2
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
2048.cpp
Terminal version of the game "2048" written in C++.
:tada: Featured on GitHub's Twitter and Facebook pages! :tada:
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
- Open your terminal in your preferred directory and clone this project:
$ git clone https://github.com/plibither8/2048.cpp
- Enter the project directory:
$ cd 2048.cpp
- Create a
build
folder (Optional):
$ mkdir build
- Compile the
2048.cpp
file and create an output using the Makefile:
$ make
- Run the program and play the game!
$ ./build/2048.out
Notes
board[y][x]
'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.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK