请具体解释一下代码逐行详细解释,十分感谢
classManageArea
{
public:
friendvoidMessageDispose();
voidTimeAdd(doubleadd) //增加时间(可在类外直接调用实现动态刷新时间)
{
m_time=add;
DisplayTime();
}
voidScoreAdd(shortadd) //增加分数(可在类外直接调用实现动态刷新分数)
{
m_score=add;
DisplayScore();
}
voidDisplayPause() //显示暂停或者开始
{
BeginBatchDraw();
_stprintf(m_str_score,_T(\"%d\"),m_score);
setfont(25,0,_T(\"微软雅黑\"));
setfillstyle(m_bgcolor);
bar(625,490,800,515);
setcolor(BLUE);
if(m_pause)
outtextxy(625,490,_T(\"开始(P键)\"));
else
outtextxy(625,490,_T(\"暂停(P键)\"));
EndBatchDraw();
}
voidInit()//初始化管理界面
{
m_time=0.0;
m_score=0;
m_leave=1;
m_pause=false;
_stprintf(m_str_score,_T(\"%d\"),m_score);//格式化转换类型
_stprintf(m_str_time,_T(\"%.1lf\"),m_time);
m_bgcolor=BLACK;
BeginBatchDraw();
setfillstyle(BLACK);
bar(601,0,800,600);
setfont(60,0,_T(\"微软雅黑\"));
setcolor(GREEN);
outtextxy(625,30,_T(\"贪吃蛇\"));
setfont(30,0,_T(\"微软雅黑\"));
setcolor(RGB(128,0,255));
outtextxy(625,140,_T(\"制作:马海超\"));
setfont(25,0,_T(\"微软雅黑\"));
setcolor(BLUE);
outtextxy(625,430,_T(\"时间:\"));
outtextxy(625,460,_T(\"分数:\"));
outtextxy(625,490,_T(\"暂停(P键)\"));
outtextxy(625,520,_T(\"重新游戏(R键)\"));
setcolor(RED);
outtextxy(720,400,m_str_leave);
outtextxy(680,460,m_str_score);
outtextxy(680,430,m_str_time);
EndBatchDraw();
}
private:
double m_time;
short m_score;
short m_leave;
bool m_pause;
TCHAR m_str_leave[2],m_str_time[33],m_str_score[5];
COLORREFm_bgcolor;
voidDisplayTime()//显示当前耗时
{
BeginBatchDraw();
_stprintf(m_str_time,_T(\"%.1lf\"),m_time);
setfont(25,0,_T(\"微软雅黑\"));
setfillstyle(m_bgcolor);
bar(680,430,800,455);
setcolor(RED);
outtextxy(680,430,m_str_time);
EndBatchDraw();
}
voidDisplayScore()//显示当前分数
{
BeginBatchDraw();
_stprintf(m_str_score,_T(\"%d\"),m_score);
setfont(25,0,_T(\"微软雅黑\"));
setfillstyle(m_bgcolor);
bar(680,460,800,485);
setcolor(RED);
outtextxy(680,460,m_str_score);
EndBatchDraw();
}
};
|