资源描述:
《打飞机c++程序代码,亲测非常有用》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#include#include#include#includeusingnamespacestd;typedefstructFrame{COORDposition[2];intflag;}Frame;voidSetPos(COORDa){HANDLEout=GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleCursorPosition(out,a);}voidSetPos(inti,intj){COORDpos={i,j};SetPo
2、s(pos);}voidHideCursor(){CONSOLE_CURSOR_INFOcursor_info={1,0};SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);}//把第y行,[x1,x2)之间的坐标填充为chvoiddrawRow(inty,intx1,intx2,charch){SetPos(x1,y);for(inti=0;i<=(x2-x1);i++)cout<3、OORDb,charch){if(a.Y==b.Y)drawRow(a.Y,a.X,b.X,ch);else{SetPos(0,25);cout<<"errorcode01:无法填充行,因为两个坐标的纵坐标(x)不相等";system("pause");}}//把第x列,[y1,y2]之间的坐标填充为chvoiddrawCol(intx,inty1,inty2,charch){inty=y1;while(y!=y2+1){SetPos(x,y);cout<4、OORDb,charch){if(a.X==b.X)drawCol(a.X,a.Y,b.Y,ch);else{SetPos(0,25);cout<<"errorcode02:无法填充列,因为两个坐标的横坐标(y)不相等";system("pause");}}//左上角坐标、右下角坐标、用row填充行、用col填充列voiddrawFrame(COORDa,COORDb,charrow,charcol){drawRow(a.Y,a.X+1,b.X-1,row);drawRow(b.Y,a.X+1,b.X-1,row);drawCol(a.X,a.Y+1,b.Y-1,col);d
5、rawCol(b.X,a.Y+1,b.Y-1,col);}voiddrawFrame(intx1,inty1,intx2,inty2,charrow,charcol){COORDa={x1,y1};COORDb={x2,y2};drawFrame(a,b,row,col);}voiddrawFrame(Frameframe,charrow,charcol){COORDa=frame.position[0];COORDb=frame.position[1];drawFrame(a,b,row,col);}voiddrawPlaying(){drawFrame(0,0,48,24
6、,'=','
7、');//drawmapframe;drawFrame(49,0,79,4,'-','
8、');//drawoutputframedrawFrame(49,4,79,9,'-','
9、');//drawscoreframedrawFrame(49,9,79,20,'-','
10、');//drawoperateframedrawFrame(49,20,79,24,'-','
11、');//drawothermessageframeSetPos(52,6);cout<<"得分:";SetPos(52,7);cout<<"称号:";SetPos(52,10);cout<<"操作
12、方式:";SetPos(52,12);cout<<"a,s,d,w控制战机移动。";SetPos(52,14);cout<<"p暂停游戏。";SetPos(52,16);cout<<"e退出游戏。";}//在[a,b)之间产生一个随机整数intrandom(inta,intb){intc=(rand()%(a-b))+a;returnc;}//在两个坐标包括的矩形框内随机产生一个坐标COORDrandom(COORDa,COORDb){intx=random(a.X,b.X);inty=random(a