Chinaunix首页 | 论坛 | 博客
  • 博客访问: 26877
  • 博文数量: 38
  • 博客积分: 2010
  • 博客等级: 大尉
  • 技术积分: 390
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-29 22:54
文章分类

全部博文(38)

文章存档

2010年(38)

我的朋友
最近访客

分类: C/C++

2010-05-29 23:05:56

听从了James关于无聊的猎杀潜艇游戏的建议打算加入会动的敌人,提高游戏性加入“战争迷雾”可谓小菜一碟而给敌人加上个最弱智的AI也不算太高难利用我擅长的INI文件处理,不难办到不过以后的地图文件会大很多[0]type=1x0=1y0=8x1=2y1=8x2=3y2=8文件后部分会出现很多这样的AI Script读取信息的函数也已经编好,下一步就是在游戏界面中实现了,明天中午GOGOGO



void CMarineDlg::GetItemInfo(int stage)

{

char* path=new char[240];

char file[MAX_PATH],number[3];

GetCurrentDirectory(240,path);

strcpy(file,path);

strcat(file,"\\map\\map");

itoa(stage+1,number,10);

strcat(file,number);

strcat(file,".thi");

char temp[10],temp2[15],temp3[10];

int i,j;

for(i=0;i<256;i++){

itoa(i,temp,10);

m_OnGame.ItemInfo[i].type=GetPrivateProfileInt(temp,"type",0,file);

if(m_OnGame.ItemInfo[i].type==0){

m_OnGame.ItemInfo[i].bIsExisted=FALSE;

break;

}

else{

for(j=0;i<16;j++)

{

strcpy(temp2,"x");

itoa(j,temp3,10);

strcat(temp2,temp3);

m_OnGame.ItemInfo[i].step[j].x=GetPrivateProfileInt(temp,temp2,100,file);

strcpy(temp2,"y");

itoa(j,temp3,10);

strcat(temp2,temp3);

m_OnGame.ItemInfo[i].step[j].y=GetPrivateProfileInt(temp,temp2,100,file);

if(m_OnGame.ItemInfo[i].step[j].x==100 || m_OnGame.ItemInfo[i].step[j].y==100){

m_OnGame.ItemInfo[i].bIsExisted=FALSE;

break;

}

else{

m_OnGame.ItemInfo[i].bIsExisted=TRUE;

m_OnGame.ItemInfo[i].now.x=m_OnGame.ItemInfo[i].step[j].x; m_OnGame.ItemInfo[i].now.y=m_OnGame.ItemInfo[i].step[j].y;

}

}

}

}

delete path;

return;

}


阅读(157) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~