好久都没有更新这个系列的专栏了,我们来康康吧。
今天,我们用C++只做一个小游戏—2048小游戏。
或许,有人会说:这太没技术含量了,简直信手捏来!
那么,用easyx呢?
台下观众:
接下来,废话不多说,咱们直接先看一下项目截图:
然后代码伺候:
#include <cstdio>
#include <cstring>
#include <ctime>
#include <graphics.h>
#include <conio.h>
#include <cstdio>
using namespace std;
const COLORREF BGC = RGB(250, 248, 239);
int score, best, a[5][5], b[5][5];
bool mov[5][5];
void init()
{
setbkcolor(BGC);
setbkmode(TRANSPARENT);
score = 0;
memset(a, 0, sizeof(a));
int x1 = rand() % 4 + 1, y1 = rand() % 4 + 1, x2 = rand() % 4 + 1, y2 = rand() % 4 + 1; // 随机生成两个初始点
a[x1][y1] = a[x2][y2] = 2;
}
void drawmap()
{
BeginBatchDraw();
cleardevice();
settextcolor(RGB(119, 110, 101));
settextstyle(50, 0, L"微软雅黑");
outtextxy(10, 10, L"2048");
settextstyle(20, 0, L"微软雅黑", 0, 0, 550, false, false, false);
outtextxy(10, 65, L"Join the numbers and get to the 2048 tile!");
setfillcolor(R