当前位置: 首页 > 工具软件 > AngelScript > 使用案例 >

绑定HGE到AngelScript脚本系统

胡景焕
2023-12-01

 

    关于脚本系统,以前接触过GameMonkey,当时的感觉就是要结合进C++,处理类方面比较麻烦。事实上大部分脚本语言要结合进C++,都存在这个问题。后来知道了Angel Script,稍微看了下文档,发现其与C++结合比较容易。

    最近都在休息,前天休息疯了,就决定玩玩angel script。后来突然就产生了把HGE和angel scrip结合起来的想法。也就是很多游戏引擎的各类脚本wrappet之类的东西。目的就是通过一些中间代码的桥接,使某个脚本语言也可以使用该引擎。我所要做的,也就是在angel script脚本代码中,也可以使用HGE来编写游戏。

    看了些文档,写了些实验代码,就开始这个我认为比较有意思的project。整个过程还是比较顺利,写到后来都是些体力活,没什么意思。

    封装了部分HGE的接口,用angel script重写了HGE第7个例子程序,用来测试效率。结果还算好,效率比本地代码慢了几个FPS(绘制1000个zazaka),只是载入速度慢了点,因为需要把脚本代码编译一次,也许在发行时,发行编译好的字节码,载入速度会快很多。

    写好后整理了下API文档(即目前我封装了哪些HGE的接口),就草草发到HGE官方论坛去了。以下是我在HGE论坛发的帖子:

    帖子原文地址: http://relishgames.com/forum/viewtopic.php?t=2766

    angel script 地址:http://www.angelcode.com/angelscript/

    帖子原文:

    Hi, all
i'm glad that i can use hge engine to create games .Besides hge is an easybut powerful engine.

And yet AngelScript is also easy use script engine. It's a c++-like script
language and it's very easy to embed into c++ native application .

And now i bind hge and AngelScript together . That means i wrapped some hge's functions classes and you can write AngelScript to make your hge games.By using script language, your most convenient is you donot need compile your code and link your code like in c++.

The most important thing is the speed, yes, i wrote hge tutorial 7(thousand of hares) in AngelScript (download below) and see what 's the difference between them. The result on my computer is the speed is almost same . But the loading time is different: the AngelScript version is slower that because the script engine should compile the script first .

You can download the demo here http://blog.blogwhy.com/azjex/upload/ashge_demo_7.rar. And there is a file named apireference.txt that document the current api i wrapped. So you can change game.as whatever you want.

So, is there somebody interested in this project ? If somebody is interested in it i will continue this work, i mean continue to wrap more hge functions(classes).

Best regards,
Kevin Lynx

    DEMO演示下载(包含API文档):

    http://blog.blogwhy.com/azjex/upload/ashge_demo_7.rar

    比较有趣的事是,现在用HGE写游戏,都不需要编译器了。只需要例子程序中的可执行文件,直接改game.as即可。

 类似资料: