2048 Game

This was a first-year project which was to build a game similar to the viral 2048 app using C++ . We were given restrictions on the utility of the game but had plenty of room for creativity and efficiency improvements. We needed to consider all possible edge cases and learnt good coding practices where the versatility of our code was also considered for marking.

The game features a four-by-four grid of numerical cells. By default, the cells' values are 0, which is equivalent to the cell being void. At the beginning of the game, the values of cells could be initialised using a pre-written text file.

The game functioned in rounds. Each round the player would perform one swipe, which displaced cell values and caused merges in some instances. The prerequisites for merges were simple rules but led to several edge cases due careful consideration. After each round, the program generates and inserts a low value to one of the void cells. The goal of the game is for the player to achieve the highest cell value possible (via merges) before being overwhelmed by the random insertions filling up the grid and being left no valid moves.

Since most monitors are not touchscreen, the swiping mechanic was implemented via the keyboard buttons w, a, s and d.