{
s[man.y][man.x-2]=2;
s[man.y][man.x-1]=4;
s[man.y][man.x]=0;
}
else
{
continue;
}
}
else if(s[man.y][man.x-1]==0 || s[man.y][man.x-1]==3)
{
s[man.y][man.x-1]=4;
s[man.y][man.x]=0;
}
else
{
continue;
}
}
int i;
for(i=0;inest_count;i++)
{
if(nest[i].x==prev.xnest[i].y==prev.y)
{
s[prev.y][prev.x]=3;
break;
}
}
Draw();
if(is_Success()==true)
{
gate++;
if(gatemap_count)
{
printf("\n\nmap is end!");
fflush(stdin);
getch();
exit(0);
}
break;
}
}
else if(sel=='q' || sel=='Q')
{
exit(0);
}
else if(sel=='r' || sel=='R')
{
break;
}
}
}
return 0;
}
void GetDataFromFile()
{
int i;
if(s!=NULL)
{
if(h!=0)
{
for(i=0;ih;i++)
{
free(s+i);
}
free(s);
}
else
{
printf("fail");
getch();
exit(0);
}
}
if(nest!=NULL)
{
free(nest);
}
map_count=GetPrivateProfileInt("MAPCOUNT","map_count",0,data_file);
if(map_countgate)
{
printf("gate finish!");
getch();
exit(0);
}
char section[20]={'\0'};
sprintf(section,"MAP%d",gate);
nest_count=GetPrivateProfileInt(section,"nest_count",0,data_file);
nest=(PT*)malloc(sizeof(PT)*nest_count);
w=GetPrivateProfileInt(section,"w",0,data_file);
h=GetPrivateProfileInt(section,"h",0,data_file);
if(w5 || h5 || nest_count1)
{
printf("w or h or box_nest data error!");
getch();
exit(0);
}
s=(int**)malloc(sizeof(int*)*h);
for(i=0;ih;i++)
{
*(s+i)=(int*)malloc(sizeof(int)*w);
}
char key[20]={'\0'};
char line[50]={'\0'};
int len;
int j;
for(i=0;ih;i++)
{
memset(line,'\0',50);
sprintf(key,"l%d",i+1);
GetPrivateProfileString(section,key,"\0",line,50,data_file);
len=strlen(line);
if(len0)
{
line[len++]=' ';
line[len]='\0';
}
GetIntFromLineString(line,strlen(line),i);
}
len=0;
for(i=0;ih;i++)
{
for(j=0;jw;j++)
{
if(s[i][j]==3)
{
nest[len].y=i;
nest[len].x=j;
len++;
}
else if(s[i][j]==5)
{
nest[len].y=i;
nest[len].x=j;
len++;
s[i][j]=2;
}
}
}
}
void strmyncpy(char* source, char* target, int begin, int end)
{
int i=0;
while(1)
{
if(source[begin]!=' ')
{
target[i]=source[begin];
}
i++;
begin++;
if(beginend)
{
target[i]='\0';
break;
}
}
}
void GetIntFromLineString(char* ch, int len, int i)
{
int j=0;
char c[5]={'\0'};
int b=0,e=0;
while(elen)
{
if(ch[e]==' ')
{
memset(c,'\0',5);
strmyncpy(ch,c,b,e);
b=e+1;
e++;
s[i][j++]=atoi(c);
}
e++;
}
}
void Draw()
{
int i,j,k;
bool flag=false;
system("cls");
printf("\n\n");
for(i=0;ih;i++)
{
printf("\n\n");
for(j=0;jw;j++)
{
if(s[i][j]==0)
{
printf("");
}
else if(s[i][j]==1)
{
printf(" ■ ");
}
else if(s[i][j]==2)
{
printf("
推荐阅读
- 蚕宝宝竞速游戏,蚕宝宝农场游戏
- 在gis里导入坐标点,坐标导入gis会有偏差
- 怎么发作品到视频号上呢,怎样发视频到视频号
- 学习通怎么直播软件免费的简单介绍
- 宝塔面板怎么使用mysql 宝塔面板部署网站
- linux查看net目录下文件的简单介绍
- 免费制作微网站,免费制作网页平台
- 头条开直播有哪些技巧,头条开直播有哪些技巧视频
- linux命令行怎么截图 linux命令行截屏