T)
{
start = now;
Time--;
New();
if (Time <= 0)
return;
}
}
if(sign)
{
putimage(x1 - x1 % 60, y1 - y1 % 60, &img[int(gem[y1 / 60 + 1][x1 / 60])], SRCPAINT);
continue;
}
if (y1 - y > 30 && y1 / 60 > 0)
fx = 'u';
if (y - y1 > 30 && y1 / 60 < 7)
fx = 'd';
if (x1 - x > 30 && x1 / 60 > 0)
fx = 'l';
if (x - x1 > 30 && x1 / 60 < 7)
fx = 'r';
x = y1 / 60 + 1;
y = x1 / 60;
x1 = y1 = 0;
switch (fx)
{
case 'u':x1 = -1; break;
case 'd':x1 = 1; break;
case 'l':y1 = -1; break;
case 'r':y1 = 1; break;
case '\0':continue;
}
for (i = 0; i < 60;)
{
putimage(60 * y, 60 * (x - 1), &img[0]);
putimage(60 * y, 60 * (x - 1), &img[0]);
i += 1;
putimage(60 * (y + y1) - i * y1, 60 * (x - 1 + x1) - i * x1, &img[int(gem[x + x1][y + y1])]);
putimage(60 * y + i * y1, 60 * (x - 1) + i * x1, &img[int(gem[x][y])]);
Sleep(2);
}
t = gem[x][y];
gem[x][y] = gem[x + x1][y + y1];
gem[x + x1][y + y1] = t;
if (judge())
{
draw();
if (!baidu())
Blank();
}
else
{
for (i = 0; i < 60;)
{
putimage(60 * y, 60 * (x - 1), &img[0]);
putimage(60 * y, 60 * (x - 1), &img[0]);
i += 1;
putimage(60 * (y + y1) - i * y1, 60 * (x - 1 + x1) - i * x1, &img[int(gem[x + x1][y + y1])]);
putimage(60 * y + i * y1, 60 * (x - 1) + i * x1, &img[int(gem[x][y])]);
Sleep(2);
}
t = gem[x][y];
gem[x][y] = gem[x + x1][y + y1];
gem[x + x1][y + y1] = t;
}
now = clock();
if (now - start >= CLOCKS_PER_SEC * MaxT / T)
{
start = now;
Time--;
New();
if (Time <= 0)
return;
}
}while (true);
}
/****************主函数******************/
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
try
{
// 加载素材
load();
}
catch (int)
{
ofstream fout("存档.dat");
fout <
}
// 打开界面
initgraph(640, 480);
// 游戏过程
do
{
if (Music)
mciSendString("play mymusic from 0 repeat", NULL, 0, NULL);
play();
if (Music)
mciSendString("stop mymusic", NULL, 0, NULL);
Flag = false;
}while (quit());
// 关闭游戏
ofstream fout("存档.dat");
fout <
fout.close();
mciSendString("close mymusic", NULL, 0, NULL);
closegraph();
return 0;
}
/**************THE END****************/
|