资源描述:
《c语言飞机大战源码》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#include#include#include#includeusingnamespacestd;/*===============allthestructures===============*/typedefstructFrame{COORDposition[2];intflag;}Frame;/*===============allthefunctions===============*/voidSetPos(COORDa)//setcurso
2、r{HANDLEout=GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleCursorPosition(out,a);}voidSetPos(inti,intj)//setcursor{COORDpos={i,j};SetPos(pos);}voidHideCursor(){CONSOLE_CURSOR_INFOcursor_info={1,0};SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);}//把第y行,[x1,x2)之间的坐标填充为
3、chvoiddrawRow(inty,intx1,intx2,charch){SetPos(x1,y);for(inti=0;i<=(x2-x1);i++)cout<4、之间的坐标填充为chvoiddrawCol(intx,inty1,inty2,charch){inty=y1;while(y!=y2+1){SetPos(x,y);cout<5、坐标、右下角坐标、用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);drawCol(b.X,a.Y+1,b.Y-1,col);}voiddrawFrame(intx1,inty1,intx2,inty2,charrow,charcol){COORDa={x1,y1};COORDb={x2,y2};drawFrame(a
6、,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,'=','
7、');//drawmapframe;drawFrame(49,0,79,4,'-','
8、');//drawoutputframedrawFrame(49,4,79,9,'-','
9、');//drawscoreframe
10、drawFrame(49,9,79,20,'-','
11、');//drawoperateframedrawFrame(49,20,79,24,'-','
12、');//drawothermessageframeSetPos(52,6);cout<<"得分:";SetPos(52,7);cout<<"称号:";SetPos(52,10);cout<<"操作方式:";SetPos(52,12);cout<<"a,s,d,w控制战机移动。";SetPos(52,14);cout<<"p暂停游戏。";SetPos(52,16);cout<<"e退出游戏。";}//在[a,
13、b)之间产生一个随机整数intrandom(inta