(接上)我最近编的程序----迷宫的地图编辑器
c语言吧
全部回复
仅看楼主
level 2
zfy0422 楼主
/*地图编辑器*//*本程序可以画迷宫地图,并自动生成0,1代码保存在一个文件里*//*使用方法:按上下左右键可以控制物体的移动,按下空格键可以画方块,再按空格键可擦去方块*//*本程序存在一些问题,因为定义的数组不是很大,也没有考虑再数组外的情况,所以最好不要移出范围内*/#include
#include
#include
#include
#include
#define LEFT 120
#define TOP 40#
define RIGHT 520
#define BOTTOM 440#
define BIG 20#define SMALL 20int a[20][20];void drawcake(int x,int y)/*划方块*/{setfillstyle(SOLID_FILL,BLUE);bar(LEFT+1+x*SMALL,TOP+1+y*SMALL,RIGHT-1-19*SMALL+x*SMALL,BOTTOM-1-19*SMALL+y*SMALL);}void undrawcake(int x,int y)/*擦去方块*/{setfillstyle(SOLID_FILL,BLACK);bar(LEFT+1+x*SMALL,TOP+1+y*SMALL,RIGHT-1-19*SMALL+x*SMALL,BOTTOM-1-19*SMALL+y*SMALL);}main(){int gr=DETECT,gm,i,j,x=1,y=1,ch;FILE *fp;float f;initgraph(&gr,&gm,"");cleardevice();setbkcolor(0);fp=fopen("迷宫地图.txt","w");printf(" 地图编辑器");for(i=0;i<20;i++){drawcake(i,0); a[i][0]=1;drawcake(i,19);a[i][19]=1;drawcake(0,i); a[0][i]=1;drawcake(19,i);a[19][i]=1;}drawcake(x,y);do{ch=bioskey(0);switch(ch){case 19200:{if(a[x][y]==0)undrawcake(x,y);else ;x--;drawcake(x,y);break;}case 19712:{if(a[x][y]==0)undrawcake(x,y);else ;x++;drawcake(x,y);break;}case 18432:{if(a[x][y]==0)undrawcake(x,y);else ;y--;drawcake(x,y);break;}case 20480:{if(a[x][y]==0)undrawcake(x,y);else ;y++;drawcake(x,y);break;}case 14624:if(a[x][y]==0){drawcake(x,y);a[x][y]=1;}else{undrawcake(x,y);a[x][y]=0;}}}while(ch!=283);cleardevice();fp=fopen("迷宫地图.txt","w");for(x=0;x<20;x++){for(y=0;y<20;y++)fprintf(fp,"%d,",a[y][x]);fprintf(fp,"\n");}fclose(fp);getch();}/*本程序所有权归计算机网络安全研究协会*//*柳云飞 2004-11-5*/
2004年11月05日 08点11分 1
level 1
不知道楼主会人工智能程序么?
2004年11月05日 08点11分 3
level 2
zfy0422 楼主
我不会的,我也是个初学者啊,连数据结构课也是刚开的,c闲人大哥,我还要向你多多学习啊。
2004年11月05日 08点11分 4
level 2
zfy0422 楼主
我昨天晚上看了一个45度RPG游戏引擎,象传奇的那样,挺有意思的,只是不知道怎么做,c闲人大哥你看吗,帮我研究一下好吗?
2004年11月05日 08点11分 5
level 1
发来看看
2004年11月05日 08点11分 6
level 2
zfy0422 楼主
以后给你吧,我现在在网吧里,我上网很不方便的
2004年11月05日 08点11分 7
level 1

2004年11月05日 08点11分 8
level 0
哇!~~~我收徒弟吗?加我279352346
2006年11月16日 23点11分 9
level 1
楼主这个程序在c++里面执行不了啊
2014年05月25日 03点05分 10
1