支持(HGE+DX9+3DS+CN及输入+网络)[+MFC]这些要看自己需不需要
前提条件:
在不影响改过的HGE与原始HGE版本没有多的改动情况下进行的.
我来解释一下此版本:
vista系统下的d3d9.dll和XP及2000下的d3d9.dll是不兼容的.也不向上向下兼容.
3DS的需求,比如你想用3D人物做2D游戏,这个时间就需要了。
CN中文输入呢我已经有了构想,不再使用以前我改过别人的一个CN方案,也不采用HGETTF,到时再公布.
网络部分不用解释.这个我已经很早就实现.只是公司一直忙项目.很久都没有出来写过东西了.也没公布.
MFC是我调试HGE程序时才用的.
另注明:
本游戏已经完成所有数据动态加载的设计.

先发几张正在做的图:
图1(拿扇子跑动的图)

图2(拿剑的图)

再预览一下部分代码:
程序的启动代码
int
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR,
int
)

...
{
HGE* hge = hgeCreate(HGE_VERSION);

tSceneManager::DESC desc;

desc.Width = 640;
desc.Height = 480;
desc.centerX = desc.Width>>1;
desc.centerY = desc.Height>>1;
desc.pApp = new demoApp(&desc);

hge->System_SetState(HGE_HIDEMOUSE, false);
hge->System_SetState(HGE_WINDOWED, true);
hge->System_SetState(HGE_SCREENWIDTH, desc.Width);
hge->System_SetState(HGE_SCREENHEIGHT, desc.Height);

if (hge->System_Initiate())

{
hge->System_RequestApp((hgeApp*)desc.pApp);
hge->System_Start();
hge->System_Shutdown();
}

hge->Release();
SAFE_DELETE(desc.pApp);

return 0;
}
脚本配置(主程序配置):
#Init

#SetRemarkd[
//
]
#SetKeyword[..]
#SetCompart[ ]

#Begin

//
名称 文件
..font config
/
font.config
..language config
/
language.config
..color config
/
color.config
..body config
/
body.config
..scene config
/
scene.config
..resource config
/
resource.config

#End
脚本配置(角色怪物NPC配置):
//
......初始化略
#Begin

//
0角色类型 1怪物类型 2NPC类型
//
类型 ID 时钟 角色文件 武器文件 名称ID 阴隐资源ID
//
角色(8个方向)
..
0
0
70
role
/
role arm
/
arm
0
10
..
0
1
70
role
/
role arm
/
arm
0
10

//
怪物(4个方向)
..
1
0
120
ogre
/
ogre NULL
10
10
..
1
1
120
ogre
/
ogre NULL
11
10
..
1
2
120
ogre
/
ogre NULL
12
10
..
1
3
120
ogre
/
ogre NULL
13
10
..
1
4
120
ogre
/
ogre NULL
14
10

//
NPC(4个方向)

#End
动态地图加载的代码(观赏用):
void
tMapScene::OnFrame(
int
cx,
int
cy,
float
ct)

...
{
TASSERT(cx >= 0 && cx < tsn_scn_w);
TASSERT(cy >= 0 && cy < tsn_scn_h);

// 角色无移动
if (tmsn_lst_cx == cx && tmsn_lst_cy == cy)

...{
return tScene::OnFrame(cx, cy, ct);
}

// 新的范围
int x1, y1, x2, y2;
GetGridBound(cx, cy, x1, y1, x2, y2, 1, true);

// 首次移动要将显示的地图加载进来
if (tmsn_lst_cx == -1 && tmsn_lst_cy == -1)

...{
for (int j = y1; j <= y2; ++j)

...{
for (int i = x1; i <= x2; ++i)
BulidGroundRes(i, j);
}
}
else

...{
// 找到需要释放节点和添加节点(以下算法会重复处理两个点)
int way_x = cx - tmsn_lst_cx, way_y = cy - tmsn_lst_cy;
int lstx1, lsty1, lstx2, lsty2;
GetGridBound(tmsn_lst_cx, tmsn_lst_cy, lstx1, lsty1, lstx2, lsty2, 1, true);

// 上,右,下,左
bool del_u = false, del_r = false, del_d = false, del_l = false;
bool add_u = false, add_r = false, add_d = false, add_l = false;

if (way_x > 0 && way_y > 0) // 0 象限,去左上,添右下
del_l = del_u = add_r = add_d = true;
else if (way_x == 0 && way_y > 0) // 1 象限,去上,添下
del_u = add_d = true;
else if (way_x < 0 && way_y > 0) // 2 象限,去右上,添左下
del_r = del_u = add_l = add_d = true;
else if (way_x < 0 && way_y == 0) // 3 象限,去右,添左
del_r = add_l = true;
else if (way_x < 0 && way_y < 0) // 4 象限,去右下,添左上
del_r = del_d = add_l = add_u = true;
else if (way_x == 0 && way_y < 0) // 5 象限,去下,添上
del_d = add_u = true;
else if (way_x > 0 && way_y < 0) // 6 象限,去左下,添右上
del_l = del_d = add_r = add_u = true;
else if (way_x > 0 && way_y == 0) // 7 象限,去左,添右
del_l = add_r = true;

if (add_u) // 添加上

...{
for (int i = x1; i <= x2; ++i)
BulidGroundRes(i, y1);
}
if (add_r) // 添加右

...{
for (int j = y1; j <= y2; ++j)
BulidGroundRes(x2, j);
}
if (add_d) // 添加下

...{
for (int i = x1; i <= x2; ++i)
BulidGroundRes(i, y2);
}
if (add_l) // 添加左

...{
for (int j = y1; j <= y2; ++j)
BulidGroundRes(x1, j);
}
if (del_u && y1 != lsty1) // 去除上

...{
for (int i = lstx1; i <= lstx2; ++i)
ClearGroundRes(i, lsty1);
}
if (del_r && x2 != lstx2) // 去除右

...{
for (int j = lsty1; j <= lsty2; ++j)
ClearGroundRes(lstx2, j);
}
if (del_d && y2 != lsty2) // 去除下

...{
for (int i = lstx1; i <= lstx2; ++i)
ClearGroundRes(i, lsty2);
}
if (del_l && x1 != lstx1) // 去除左

...{
for (int j = lsty1; j <= lsty2; ++j)
ClearGroundRes(lstx1, j);
}
}

tmsn_lst_cx = cx, tmsn_lst_cy = cy;

tScene::OnFrame(cx, cy, ct);
}
OK.就先介绍到这里,这个游戏将会开源,包括HGE的修改代码.甚至所有.SVN地址暂时不发布.
有兴趣的可以一起来研究研究..blog.youkuaiyun.com/showlong.
Showlong. 2008-03-17