来预览一下我业余时间正在写的一个游戏(HGE+DX9+3DS+CN及输入+网络)[+MFC]
2008-03-17 10:43
435 查看
支持(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.csdn.net/showlong.
Showlong. 2008-03-17
前提条件:
在不影响改过的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.csdn.net/showlong.
Showlong. 2008-03-17
相关文章推荐
- 例题:请输入一个时间,判断是一天中的哪个时间。逻辑思维比较强的一个题。主要复习一下if else语句
- 编写一个程序读入一行输入,然后反向打印该行,您可以把输入存储在一个char数组中: 假定该行不超过255个字符。回忆一下,您可以使用具有%c说明符的scanf()从输入中一次 读入一个字符,而且当您按下回车键时会产生换行符(/n)
- 用业余时间 复习下以前的语法 写了一个银行利率计算器 支持各种算法 和自定义利率
- 如何制作一个简单的蓝牙网络多人扑克游戏第一部分
- 题目:输入一个已经按升序排序过的数组和一个数字, 在数组中查找两个数,使得它们的和正好是输入的那个数字。 要求时间复杂度是O(n)。如果有多对数字的和等于输入的数字,输出任意一对即可。 例如输入数组1、2、4、7、11、15和数字15。由于4+11=15,
- 尽管是一个CS专业的学生,小B的数学基础很好并对数值计算有着特别的兴趣,喜欢用计算机程序来解决数学问题。现在,她正在玩一个数值变换的游戏。她发现计算机中经常用不同的进制表示同一个数,如十进制数123表达为16进制时只包含两位数7、11(B),用八进制表示时为三位数1、7、3。按不同进制表达时,各个位数的和也不同,如上述例子中十六进制和八进制中各位数的和分别是18和11。
- 一个手机上的网络聊天游戏(图)
- 一个手机上的网络聊天游戏(图)
- 一个手机上的网络聊天游戏(图)
- 前段时间看到的一个处理GIF图像的方法,记录一下
- 因为应用代码正在发送一个输入同步呼叫,所以无法执行传出地呼叫
- 输入一个数组和一个数字,在数组中查找两个数,使得它们的和正好是输入的那个数字 时间复杂度O(NlogN)
- 从输入一个URL到页面呈现,网络上都发生了什么?
- C# 输入一个数字,判断大于或者小于随机数——猜钱游戏
- 我想做一个网络游戏
- 基于ACE设计一个c++网络游戏服务器框架引擎
- 串口数据写入excel出错:因为应用程序正在发送一个输入同步呼叫,所以无法执行呼出的呼叫。
- C#2.0 做一把时间锁:在系统空闲的时候弹出一个窗体,需要输入密码
- 业余时间写的一个项目的大致流程,欢迎拍砖
- 应用程序正在发送一个输入同步呼叫。。。