开发者

Adding new Game Types without recompiling the program? (C++)

I have a game which has different game types, i.e Time Trial, Infinite Game etc.

Each game type has different timing rules and potentially collision rules. Obviously in the Time Trial the game ends when the time runs out.

I am currently adding game types by 'hardcoding' them into the program, therefore each time I want to add a new game type I have to recompile the whole program.

Basically to make adding game types easier I don't want to have to recompile everything. So potentially new game types could be downloadable content and would work simply by putting the new type in the game folder.

How would one go about doing this? I assume it is with the use of libs or dlls or something (I have very little knowledge about开发者_运维问答 that so I might be completely incorrect).

I hope that all makes sense and I hope you guys can help me out or atleast point me in the direction of a book or article that explains this methodology.

Thanks in advance.


Using native DLL for game extensibility is IMO not a good idea, especially if the code is not designed for this from ground up.

You would best employ some scripting language like LUA or Python, so game modes can be added without writing and compiling C++ code. These are quite easy to implement (especially with if you use some binding/wrapper library), but require you to design a scripting API which can be a nontrivial task (depending on how much you want the game to be modifiable). This is now quite standard approach in game industry - most commercial games have some sort of scripting support these days.

Generally, the trend is to move as much code from core (C++) to scripts, because these scripts are easier to develop, maintain and modify. Many modern games have quite clean distinction between gameplay logic (written in scripting language) and game engine (written in C++ or another compiled language).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜