无聊,在公司写了个2048小游戏的程序,聊以自娱。(事实是我手机坏了,没得玩)。 很简单,直接上代码了。
#include <iostream>
#include <windows.h>
#include <ctime>
using namespace std;
int const ROW = 4;
int const COL = 4;
int game[ROW][COL] = {0};
//上下左右
int const UP = 1;
int const DOWN = 2;
int const LEFT = 3;
int const RIGHT = 4;
//游戏所处的状态
int const GAME_OVER = 1;
int const GAME_WIN = 2;
int const GAME_CONTINUE = 3;
enum GameNum
{
Game_2 = 2,
Game_4 = 4,
Game_8 = 8,
Game_16 = 16,
Game_32 = 32,
Game_64 = 64,
Game_128 = 128,
Game_256 = 256,
Game_512 = 512,
Game_1024 = 1024,
Game_2048 = 2048,
};
//打印所得的数组
void Print()
{
system("cls");
cout << "***************** 2048 控 制 台 版 ******************" << endl;
cout << "***************** By Tanzf (Intern) ******************" << endl << endl;
for (int i = 0; i < ROW; ++i)
{
cout << "---------------------------------"<< endl;
for (int j = 0; j < COL; ++j)
{
if (game