70,018
社区成员




void PauseGame(int count, void (*pfnToDo)())
{
int flag=1, i=0;
ClearKeyState();
OutTextXY(491, 349, 626, 364, "暂停中…", YELLOW, BLACK);
if(pfnToDo!=NULL) (*pfnToDo)();
Box(491, 349, 626, 364, BLACK);
ClearKeyState();
OutTextXY(491, 349, 626, 364, "即将继续", YELLOW, BLACK);
while((inportb(0x03da)&0x0008==0));
while((inportb(0x03da)&0x0008==1));
while(1)
{
if((inportb(0x03da)&0x0008)==0&&flag!=0)
{
if(i==count) break;
i++;
flag=0;
}
else if((inportb(0x03da)&0x0008)!=0&&flag==0)
{
flag=1;
}
}
Box(491, 349, 626, 364, BLACK);
}
int GameCtrl(int count)
{
int res;
time_t t;
/* 程序控制 */
if(GetKeyState(KEY_ESC))
{
OutTextXY(491, 349, 626, 364, "确定要退出吗?", YELLOW, BLACK);
OutTextXY(491, 365, 626, 380, "按Y退出", YELLOW, BLACK);
if(BIOSKey()==KEY_Y) QuitGame();
Box(491, 349, 626, 364, BLACK);
Box(491, 365, 626, 380, BLACK);
}
if(GetKeyState(KEY_P)||GetKeyState(KEY_PAUSE))
{
PauseGame(count, Pause);
}
if(GetKeyState(KEY_F8))
{
PauseGame(count, SetKeys);
}
if(GetKeyState(KEY_F6))
{
ClearKey(KEY_F6);
g_byPause=!g_byPause;
}
if(!IsPlaying())
{
PlayMusic();
}
switch(GameAction(count))
{
case 1:
t=clock();
OutTextXY(491, 349, 626, 364, "过关", YELLOW, BLACK);
while(clock()-t<=CLK_TCK);
Box(491, 349, 626, 364, BLACK);
if(StartGame(++g_nLv))
{
return -1;
}
else
{
OutTextXY(491, 349, 626, 364, "胜利", YELLOW, BLACK);
break;
}
case -1:
OutTextXY(491, 349, 626, 364, "失败", YELLOW, BLACK);
break;
case 0:
return count;
}
OutTextXY(491, 365, 626, 380, "按 ESC 退出", YELLOW, BLACK);
while(1)
{
if(GetKeyState(KEY_ESC))
{
QuitGame();
}
}
}
int main()
{
int flag=1;
int count=0;
Init();
if(!StartGame(1))
{
OutTextXY(491, 349, 626, 364, "找不到 01.map", YELLOW, BLACK);
OutTextXY(491, 365, 626, 380, "按 ESC 退出", YELLOW, BLACK);
while(!GetKeyState(KEY_ESC));
QuitGame();
}
while((inportb(0x03da)&0x0008==0));
while((inportb(0x03da)&0x0008==1));
while(1)
{
if((inportb(0x03da)&0x0008)==0&&flag!=0) /* 屏幕回扫结束 */
{
count=GameCtrl(count);
count++;
if(count>=80) count=0;
flag=0;
}
else if((inportb(0x03da)&0x0008)!=0&&flag==0)
{
flag=1;
}
}
}