Skip to content

freedom99/2048.cpp

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

2048.cpp

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
  • AI (Abandoned indefinitely)

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

  • 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)
  • CMake

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
  1. Create and enter the build directory:
$ mkdir build && cd build
  1. Compile the program with cmake
$ cmake ..
  1. Build the executable
$ make
  1. Run the program and play the game! ๐ŸŽ‰
$ ./2048

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.

About

๐ŸŽƒ Hacktoberfest is here! โ€” ๐ŸŽฎ Terminal version of the game "2048" written in C++ 11

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 99.3%
  • CMake 0.7%