打星星游戏
来源:互联网 发布:视频行为分析算法 编辑:程序博客网 时间:2024/04/27 16:14
//大一暑假#include <stdio.h>#include <stdlib.h>#include <conio.h>#define n 10//地图大小 int m=1; int g=5;//////////////////////////人是1,墙是9,星星是8/10,空位是0,光是2;int count=0;int point='w';void move(int a[][10],int i,int j);//移动函数void huatu(int a[n][n]);//画图void guang(int a[][10]);int main(void){int a[n][n]={{9,9,9,9,9,9,9,9,9,9},{9,0,0,0,9,1,0,8,8,9},{9,0,0,0,9,0,0,0,0,9},{9,0,0,0,0,0,0,0,0,9},{9,0,8,0,0,0,0,0,0,9},{9,0,0,0,0,0,9,0,0,9},{9,0,0,0,0,0,9,0,0,9},{9,0,0,8,8,0,0,0,0,9},{9,0,0,0,9,0,0,0,0,9},{9,9,9,9,9,9,9,9,9,9}}; int ch; huatu(a); while(1) { ch=getch();switch(ch){case 72: move(a,-1,0);break;case 80: move(a,1,0);break;case 75: move(a,0,-1);break;case 77: move(a,0,1);break;case 'w': point='w';continue;case 's': point='s';continue;case 'a': point='a';continue;case 'd': point='d';continue;case 'j': guang(a);break;};system("cls");huatu(a);if(count==5)/////////终止条件{ printf("成功\n");_sleep(1000);exit(0);}} return 0;}void move(int a[][10],int i,int j){ if(a[m+i][g+j]==9||a[m+i][g+j]==8)printf("撞墙或星星了"); //人-墙/星星 else if(a[m+i][g+j]==0)//人-无{a[m][g]-=1;a[m+i][g+j]+=1;m+=i;g+=j;}}void guang(int a[][10]){int i,j; if(point=='w')for(i=m-1;i>0 && a[i][g]!=9;--i){a[i][g]+=2;if(a[i][g]==10)++count;}else if(point=='s')for(i=m+1;i<9 && a[i][g]!=9;++i){a[i][g]+=2;if(a[i][g]==10)++count;}else if(point=='a')for(i=g-1;i>0 && a[m][i]!=9;--i){a[m][i]+=2;if(a[m][i]==10)++count;}else if(point=='d')for(i=g+1;i<9 && a[m][i]!=9;++i){a[m][i]+=2;if(a[m][i]==10)++count;}/////////////////////////显示攻击system("cls");huatu(a);_sleep(200);for(i=1;i<n-1;++i)///////被攻击后就变为0for(j=1;j<n-1;++j)if(a[i][j]==2 || a[i][j]==10)a[i][j]=0;}void huatu(int a[n][n]){ int count=0; int i,j; for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(a[i][j]==5)count++; switch (a[i][j]) { case 9:printf("■");break; case 0:printf(" ");break;case 10: case 2:printf("□");break;//攻击 case 1:printf("㊣");break;///人 case 8:printf("☆");break;//星星 default: printf("?");}}printf("\n"); } printf("\n\n按上下左右移动;;;;w s a d调整攻击方向;;; j攻击");}
0 0
- 打星星游戏
- 星星打地鼠游戏
- ubuntu linux 终端 pop star 打星星游戏
- 打游戏
- 纯js 消灭星星游戏,js 消灭星星游戏实现原理,有道具的消灭星星
- 用pharser 开发 消灭星星游戏【草稿】
- cocos creator第一个星星游戏
- 星星
- 星星!
- 星星
- 星星
- 星星
- 星星
- 星星
- 星星
- 星星
- 星星
- 星星
- python re.search 和 re.match 正则表达式
- 大整数的阶乘
- NYOJ 198 数数
- 《软件学报》《计算机学报》《计算机研究与发展》为计算机类三大权威刊物
- 密码学基础知识(五)序列密码
- 打星星游戏
- 图片展示(手动左右切换)
- 文件ha开发的问题,及解决方法
- java细节总结
- 【数字图像处理之二】图像直方图均衡化
- Sql Server 存储过程可选参数
- Android Studio添加库的方式
- 算术表达式
- Openstack NUMA分析与使用