#include
#include
#include精彩内容,尽在百度攻略:https://gl.baidu.com
#include
#define N 35
void print(int [][N]);//输出精彩内容,尽在百度攻略:https://gl.baidu.com
void movebul(int [][N]);//子弹移动
void movepla(int [][N]);//敌机移动
void setting();//设置精彩内容,尽在百度攻略:https://gl.baidu.com
void menu();//菜单
int scr[22][N]={0},pl=9,width=24,speed=3,density=30,score=0,death=0;//界面,位置,宽度,速度,密度,分数,死亡
main()精彩内容,尽在百度攻略:https://gl.baidu.com
{
menu();
int i=0,j=0,c;精彩内容,尽在百度攻略:https://gl.baidu.com
scr[21][pl]=1;
scr[0][5]=3;
while(1) //控制阶段(开始)精彩内容,尽在百度攻略:https://gl.baidu.com
{if(kbhit())switch(getch())
{case 'a':
case 'A': if(pl>0) scr[21][pl]=0,scr[21][--pl]=1;break;精彩内容,尽在百度攻略:https://gl.baidu.com
case 'd':
case 'D': if(pl
case 'w':精彩内容,尽在百度攻略:https://gl.baidu.com
case 'W': scr[20][pl]=2;break;
case 27: setting();break;
} //控制阶段(结束)精彩内容,尽在百度攻略:https://gl.baidu.com
if(++j%density==0)
{j=0;srand(time(NULL));
c=rand()%width;精彩内容,尽在百度攻略:https://gl.baidu.com
scr[][c]=3;
}
if(++i%speed==0)精彩内容,尽在百度攻略:https://gl.baidu.com
movepla(scr);
movebul(scr);
print(scr);精彩内容,尽在百度攻略:https://gl.baidu.com
if(i==30000)i=0;
}
return 0;精彩内容,尽在百度攻略:https://gl.baidu.com
}
void menu()//菜单精彩内容,尽在百度攻略:https://gl.baidu.com
}
printf("A,D控制方向,W发射子弹\n设置Esc\n按任意键开始\nby:Lzh"); if (getch()==27)setting();精彩内容,尽在百度攻略:https://gl.baidu.com
void print(int a[][N])//输出
{
system("cls");精彩内容,尽在百度攻略:https://gl.baidu.com
int i,j;
for (i=0;i<22;i++)
{a[i][width-1]=4;精彩内容,尽在百度攻略:https://gl.baidu.com
for (j=0;j
{if(a[i][j]==0)printf("");
if(a[i][j]==1)printf("\5");精彩内容,尽在百度攻略:https://gl.baidu.com
if(a[i][j]==2)printf(".");
if(a[i][j]==3)printf("\3");
if(a[i][j]==4)printf("|");精彩内容,尽在百度攻略:https://gl.baidu.com
if(i==0&&j==width-1)printf("得分:%d",score); if(i==1&&j==width-1)printf("死亡:%d",death); if(i==2&&j==width-1)printf("设置:Esc");
if(i==3&&j==width-1)printf("机智的我编的__LZH"); }
printf("\n");精彩内容,尽在百度攻略:https://gl.baidu.com
}
}
精彩内容,尽在百度攻略:https://gl.baidu.com
void movebul(int a[][N]) //子弹
{
int i,j;精彩内容,尽在百度攻略:https://gl.baidu.com
for (i=0;i<22;i++)
for (j=0;j
{if (i==0&&a[i][j]==2)a[i][j]=0;精彩内容,尽在百度攻略:https://gl.baidu.com
if (a[i][j]==2)
{
if(a[i-1][j]==3)score+=10,printf("\7");精彩内容,尽在百度攻略:https://gl.baidu.com
a[i][j]=0,a[i-1][j]=2;
}
}精彩内容,尽在百度攻略:https://gl.baidu.com
}
void movepla(int a[][N]) //敌机精彩内容,尽在百度攻略:https://gl.baidu.com
{
int i,j;
精彩内容,尽在百度攻略:https://gl.baidu.com
for (j=0;j
void setting()精彩内容,尽在百度攻略:https://gl.baidu.com
{
} //设置