C++ 和 EasyX 图形库,实现2048小游戏,供大家参考,具体内容如下

MainGame2048.cpp
/** Name: Game2048CoreClass*/
#include<iostream>
#include<graphics.h>
#include<stdio.h>
#include<windows.h>
#include<conio.h>
#include<stdio.h>
#include"Game2048.h"
#define BLOCK_SIZE 60
#define SIZE_COL 10
#define SIZE_ROW 10
using namespace std;
void DisplayMap(Game2048& mygame);
int GetMove();
int main(int argc, char * argv[])
{
HWND hwnd=initgraph(SIZE_COL*BLOCK_SIZE, SIZE_ROW*BLOCK_SIZE);
setbkmode(TRANSPARENT);
setbkcolor(RGB(180,180,180));
settextcolor(RGB(0,180,80));
cleardevice();
while (1)
{
Game2048 mygame(SIZE_ROW, SIZE_COL);
while (1)
{
DisplayMap(mygame);
int mov = GetMove();
cout << mov << endl;
if (!mygame.Run(mov))
break;
}
if (MessageBox(hwnd, "游戏结束,是否重玩?", "Tips", MB_YESNO) == IDNO)
break;
}
return 0;
}
int GetMove()
{
char move = '
