C语言飞机大战程序思路,c语言飞机大战源代码

#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

{

} //设置

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值