//游戏初始化
BOOL InitGame()
{
char *strTemp=NULL;
//创建后台临时表面
CreateBitmap(lpDDSBackGround, ScreenWidth, ScreenHeight);
CreateBitmap(lpDDSSour, ScreenWidth, ScreenHeight);
CreateBitmap(lpDDSTemp, ScreenWidth, ScreenHeight);
Events.GoldPointLogo("pic//interface//logo.bmp", RGB(255,255,255),
190, 170, 272, 112, 7);
//获取当前路径
GetCurrentDirectory(256, CurrentPath);
//打开游戏主配置文件
GameIni.Open("ini//heroland.ini");
//透明色
int r=GameIni.ReadInt("ColorKey","Red");
int g=GameIni.ReadInt("ColorKey","Green");
int b=GameIni.ReadInt("ColorKey","Blue");
ColorKey=RGB(r,g,b);
//初始化字体
font.InitFont(16, "宋体");
//初始化字体
strTemp = GameIni.ReadText("配置文件","字体");
DebugFont.LoadFont(strTemp, "版本字体");
_FREE(strTemp);
// 进度条
Proess.LoadIni("ini//menu//proess.ini", "进度条");
//初始化编辑器专用图素图片
strTemp=GameIni.ReadText("编辑器","ToolPic");
CreateBitmap(lpDDSTools, 0,0, strTemp);
DDSetColorKey(lpDDSTools, ColorKey);
_FREE(strTemp);
//初始化光线图片
CreateBitmap(lpDDSMask, 0,0, "pic//mask.bmp" );
//初始化图素图片
Max_GroundPic=GameIni.ReadInt("地图元素","Max_GroundPic");
lpDDSMap=new LPDIRECTDRAWSURFACE[Max_GroundPic];
for(int i=0; i<Max_GroundPic; i++)
{
strTemp = GameIni.ReadText("地图元素",i);
CreateBitmap(lpDDSMap[i], 0,0, strTemp);
DDSetColorKey(lpDDSMap[i], ColorKey);
_FREE(strTemp);
}
//初始化光标
strTemp = GameIni.ReadText("配置文件","光标");
CCursor::Init(strTemp, "header");
_FREE(strTemp);
//初始化对话框
strTemp = GameIni.ReadText("配置文件","对话框");
talk.Init(strTemp, "普通对话");
_FREE(strTemp);
//初始化消息框
strTemp = GameIni.ReadText("配置文件","消息框");
GameMessage.LoadMsgWindowIni(strTemp, "游戏消息");
_FREE(strTemp);
//初始化菜单系统
strTemp = GameIni.ReadText("配置文件","菜单系统");
Menu.LoadMenuIni(strTemp, "菜单系统");
_FREE(strTemp);
strTemp = GameIni.ReadText("配置文件","物品列表");
Menu.Goods.LoadGoodsIni(strTemp);
_FREE(strTemp);
strTemp = GameIni.ReadText("配置文件","魔法列表");
Menu.Magic.LoadMagicIni(strTemp);
_FREE(strTemp);
//初始化地图
map.InitMap(32,32);
strTemp = GameIni.ReadText("配置文件", "动态图块");
map.LoadAniCell(strTemp, "动态图块");
_FREE(strTemp);
talk.OpenFile("maps//talk.txt");
//初始化脚本解释机
strTemp = GameIni.ReadText("配置文件","脚本指令");
char *index = GameIni.ReadText("配置文件","脚本变量");
Script.Init(strTemp, index);
_FREE(strTemp);
_FREE(index);
//初始化战斗
Fight.Init();
//初始化敌人列表
CFight::LoadEnemyList("ini//fight//enemy.ini", "敌人列表");
//为新游戏初试数据
NewGame();
//读入模式
g_ePlayState = g_ePlayState_Old = (enum ePLAYSTATE)GameIni.ReadInt("Start","PlayState");
g_eDisplayState = (enum eDISPLAYSTATE)GameIni.ReadInt("Start","DisplayState");
SetTimer(hWnd, 1, 5000, NULL); //时钟
//debug方式
g_bDebug = GameIni.ReadInt("Start","Debug");
//封面
Title.LoadTitleIni( "ini//menu//title.ini", "封面");
Title.DoMenu(lpDDSBack);
return true;
}