[2006-05-07]打算编个超傻的AI,只会来回走动的,却发现已经接近24点

本文介绍了一个游戏开发项目的进展,包括如何通过加入动态敌人和简单的人工智能来增强游戏体验。作者利用INI文件处理技术实现这一目标,并讨论了地图文件增大的问题及其解决方案。
听从了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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值