Code Monkey home page Code Monkey logo

cpp-game-2048's Introduction

About Game 2048 : Initially there is borad of 4x4 arrray on which there will be empty tiles. When you start the gane there will be two tiles displayed on grid , each contain 2 or 4. When user hit the arrow key there wil generate more rabdom numbers and when two same tiles face each other they will merg into one by adding i.e 2+2=4 ans so on.

Game Based : language used : c++ IDE/Tool used : visual studio 2019 pr0fessional conatain diagnostic tool User interface : Black console version : student version

Goals: (1) The goal of the game is to create a tile 2048 from the randon tiles created on board. (2)Provide a good and user friendly interaface. (3) There are options for restarting, quit the agme 2048

How to play the game?

(1)Use the keyboard directional arrow keys to the tiles in a certain direction. (2)Press end key to exit the game (3) press escape key to restart the game (4) when two same tiles face each other , they merge into one and give new number i.e by addition

Algorithm: I chose to store the field in a two-dimensional array called board that is 4×4.

1=[2][0][8][2]          [2][4][8][4]
2=[0][4][0][2]  press   [4][8][4][4]
3=[4][0][2][2]  up key  [0][0][0][0]
4=[0][8][2][2]          [0][0][0][0]

The algorithm can also be explained as

=> To take a search over the two dimensional array from the first to the last number => In the array for each original number in the array that is not zero look backwards for a target position that does not contain a zero //unless it is position zero => if the target position does not contain the original number use the next position => if the target position is different from the original position - add the number to the number on the target position

Snapshots

1 (initially)

image

(2) After moving some tiles , screen

image

(3) When user press Escape key ,want to restart the game

image

(4) when user press END key to exit the game

image

(5)

image

(6) when game over function is called

image

cpp-game-2048's People

Contributors

ziakhan1995 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.