diff --git a/.gitignore b/.gitignore index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1ee1633605b2ccacb90cbf77dcc0073a8664ac4b 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,3 @@ +build/ +.vscode +Screenshots \ No newline at end of file diff --git a/2048.cpp b/2048.cpp index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..dfbdf741a0dfffac7873a8bc01872aa78ee8c1e3 100644 --- a/2048.cpp +++ b/2048.cpp @@ -0,0 +1,30 @@ +#include "game.hpp" + +#include <iostream> +#include <cstdlib> +#include <iomanip> + +Board::Board() { + //create a 2D array using std::vector using int for boolen values in + board = std::vector<std::vector<int>>(4, std::vector<int>(4, 0)); + STARTER_TILE(); + STARTER_TILE(); +} + +void CREATE_BOARD(){ + std::cout << "-*-*-*-*-*-*-*-*-*-*-*-*-*-*-" << std::endl; //just adds boarder + + for (size_t X = 0; X < board.size(); X++) // This loops through the row or the X axis using board.size to loop the correct amount. + { + for (size_t Y = 0; Y < board.size(); Y++) // This loops throughthe colums or the Y axis + { + int tile = board[X][Y]; + } + std::cout << std::endl; + } + std::cout << "-*-*-*-*-*-*-*-*-*-*-*-*-*-*-" << std::endl; +} + +void STARTER_TILE(){ + +} \ No newline at end of file diff --git a/README.md b/README.md index fb8068a8d0ca9e332d42d6d70c0d79cb8ca90e23..210d6f4590a53f2ad31f132631ba1a175adb2188 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,23 @@ # 2048 Game -## In this Code I am going to be recreating [this game](https://play2048.co/) in a linux command line. +[The Rules](#rules) + + + +## In this Code I am going to be recreating the classic[2048](https://play2048.co/) in a linux command line. # The Rules -* If 2 of the same numbers touch they will combine and add up to the value of both added together (e.g. if a 2 block touches another 2 block they will combine and become one 4 block) +* If 2 of the same numbers touch they will combine and add up to the value of both + added together (e.g. if a 2 block touches another 2 block they will combine and become one 4 block). -* You can use the 2 common layouts of cursor keys (arrow keys or wasd) +* You can use the 2 common layouts of cursor keys (arrow keys or wasd). + +* If there is no empty cells left with no valid moves then the game will end.. ## The Aim -The aim of the game is to get one of the blocks upto a score of 2048 \ No newline at end of file +The aim of the game is to get one of the blocks upto a score of 2048 + +### How its srtuctured + +First of all the board is created and 2 randomly placed and valued numbers are added diff --git a/game.hpp b/game.hpp index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..5b896a84e5d3cd02784399d7204abcd52b49ea55 100644 --- a/game.hpp +++ b/game.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include <vector> + +class Board { +private: +std::vector<std::vector<int>> board; + +public: +Board(); +void CREATE_BOARD(); + +}; \ No newline at end of file diff --git a/main.cpp b/main.cpp index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e84f1bc79747685d5e6a747393a3451358df6688 100644 --- a/main.cpp +++ b/main.cpp @@ -0,0 +1,7 @@ +#include "game.hpp" + +int main(){ + Board game; + + return false; +} \ No newline at end of file