Closed domob1812 closed 5 years ago
First experimental implementation of this (including the C# interop library) is in 09456de25fd2dc4ec9731333345dd5ce60efed27. Before this can be merged to master, it needs refactoring with proper unit tests and will be tested by @RyuMaster for actual usability from C#.
It seems that C# interop is a bit different - since C# is not linked in the normal way, it is not easily possible to "just" fill in the undefined functions from C#. Instead, it seems easier to provide callbacks in C# and pass those as function pointers to C++.
I've updated the work in progress now (30b617104a0ae251b4edb396c870122f72d16f29) to reflect that.
f98494484800fae2e23034732eac8950b248bf35 added a utility DefaultMain
function, to make the main
from mover reusable for other projects in the future.
What we should still work out here (@RyuMaster is working on it) is how to best write a C++ "main" function that can be integrated easily with C#.
The core
libxayagame
is intentionally designed to be primarily a library. It makes it easy to write a game daemon, but there has to be somemain
function provided which handles things like configuration and command-line flags.To make it even easier for game developers and to avoid duplicated code, we should provide a separate library that can be linked to with a "default main" that does all that. I.e. the user would still provide a
main
, but it would only have to instantiate theGameLogic
and pass that together with the game ID to the provided default main. Standard configuration and command-line flags would be done by that.Going one step further, we could also provide another library that has a real
main
function, but calls declared and not definedextern "C"
functions from it for the game-specific logic. That would make it easily possible to write simple games in a language other than C++ (e.g. C#) as long as it allows to provide C-callable functions.