2024年8月6日发(作者:)

void GameDraw() {
cleardevice();
for (size_t i = 0; i < STR_NUM; i++) {
for (size_t j = 0; j < STR_SIZE; j++) {
outtextxy(rain[i].x, rain[i].y - STR_WIDTH * j, rain[i].str[j]);
settextcolor(RGB(0, 255 - (13 * j), 0));
}
}
}
void GamePlay() {
for (size_t i = 0; i < STR_NUM; i++) {
rain[i].y += rain[i].speed;
if (rain[i].y - STR_SIZE * STR_WIDTH > WIDTH) {
rain[i].y = 0;
}
}
}
void ChangeCh() {
for (size_t i = 0; i < STR_NUM; i++) {
rain[rand() % STR_NUM].str[rand() % STR_SIZE] = CreateCh();
}
}
int main() {
initgraph(WIDTH, HEIGHT);
srand(GetTickCount());
DWORD t1, t2;
t1 = t2 = GetTickCount();
GameInit();
while (true) {
BeginBatchDraw();
GameDraw();
ChangeCh();
if (t2 - t1 > 20) { // 使游戏下落延时
GamePlay();
t1 = t2;
}
t2 = GetTickCount();
EndBatchDraw();
// Sleep(20); // 使整个程序延时
}
getchar();
closegraph();
return 0;
}
本文发布于:2024-08-06 07:39:39,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/1722901179293025.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
| 留言与评论(共有 0 条评论) |