小白来问问题啦求高手指教啊
目的: 有2张地图 在船进入村那个点的时候自动进入小地图(第2张) 然后小地图也能有出口回到大地图 并且还能继续在大地图里正常进行下去2张地图都是适当的偷懒了 现在只是想问下 怎么才能实现上面提到的目的? 思路很混乱
下面我贴码(请把上述功能实现的前提下修改完整这段码) 顺便把附件也发一下吧(乱码汉字出现 请无视)
主文件:
#include <stdio.h>
#include <stdlib.h>
#define UMI 0
#define RIKU 1
#define FUNE 2
#define MURA 3
#define GYO 13
#define RETU 22
int endflag=0;
int shipx=0;
int shipy=0;
int treasurex=18;
int treasurey=13;
int MURAx=6;
int MURAy=2;
int map[GYO][RETU]={0};
void move(void);
void makemap(void);
void message(void);
void ending(void);
void makemap(void)
{
int i,j;
char dummy;
FILE *fp;
fp = fopen("map.dat","map2.dat","r");
if(fp == NULL){
printf("幐攕偟傑偟偨丅\n");
exit(1);
}
for(i=0;i<GYO;i++){
for(j=0;j<RETU;j++){
fscanf(fp,"%d%c",&map[i][j],&dummy);
}
}
fclose(fp);
map[shipx][shipy]= FUNE;
}
void move()
{
int i;
int x,y;
x=shipx;
y=shipy;
printf("\n堏摦愭傪擖椡偟偰偔偩偝偄丅>");
scanf("%d",&i);
if(i==2){shipx++;}
else if(i==4){shipy--;}
else if(i==6){shipy++;}
else if(i==8){shipx--;}
if(shipx>13){shipx=13;}
if(shipy>22){shipy=22;}
if(shipx<0){shipx=0;}
if(shipy<0){shipy=0;}
if(map[shipx][shipy]==RIKU){shipx=x; shipy=y;}
if(map[shipx][shipy]==MURA){shipx=x; shipy=y;}
if((shipx==treasurex)&&(shipy==treasurey)){endflag=1;}
}
void message()
{
int i,j;
for(i=0;i<GYO;i++){printf("-");}
printf("\n");
for(i=0;i<GYO;i++){
for(j=0;j<RETU;j++){
if(map[i][j]==UMI){printf("?");}
else if(map[i][j]==RIKU){printf("鵂");}
else if(map[i][j]==FUNE){printf("?");}
else if(map[i][j]==MURA){printf("懞");}
}
printf("\n");
}
for(i=0;i<GYO;i++){printf("-");}
printf("\n");
}
void ending()
{
printf("偍傔偱偲偆両\n");
}
int main(void)
{
while(endflag!=1){
makemap();
message();
move();
}
ending();
return(0);
}
地图:
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,
0,0,0,1,1,3,0,0,0,1,1,0,0,1,1,0,0,0,1,1,1,1,
0,1,1,1,1,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,0,
0,1,1,0,1,1,0,0,0,1,1,0,1,1,0,0,1,1,0,0,0,1,
0,1,1,0,0,1,0,0,0,0,1,0,1,1,0,0,1,1,0,0,0,1,
0,0,1,1,0,0,0,1,1,0,0,1,1,0,0,1,1,0,0,0,1,1,
0,0,1,1,0,0,0,1,1,0,1,0,0,0,0,0,0,1,1,0,0,0,
0,0,1,0,0,0,0,1,1,0,1,1,0,0,1,1,0,0,0,1,0,0,
1,0,0,0,1,0,0,0,0,0,1,0,1,1,0,0,1,1,0,0,0,1,
1,1,1,0,0,1,1,0,0,1,1,0,1,1,0,0,1,1,0,0,0,1,
0,0,0,1,1,1,0,0,1,0,1,1,0,0,0,1,0,0,0,1,1,1,
0,1,1,1,1,1,1,0,0,1,0,1,1,0,0,1,1,0,0,0,1,0,
以上
新建文件夹.rar
(1.45 KB)
求高手出现 谢谢了