Hi, there.
I will write base system in C++ and main system in AngelScript.
The base system will provide the main system interfaces needing for game development(like a game engine).
I looked over the source codes under the samples directory however I didn't get what should I do.
My purposes are to interact with each other and not to take time for native function calls written in C++ if possible.
I think that the event exsample seems the nearest code what I want to do.
I will carry out them to do the following:
// A script has been loaded and built.
// My application uses only one module and context.
asIScriptModule *mod = engine->GetModule("MyModule");
// Find the callback functions.
asIScriptFunction *onWait = mod->GetFunctionByDecl("void onWait()");
asIScriptFunction *onRender = mod->GetFunctionByDecl("void onRender()");
// etc...
asIScriptContext *ctx = engine->GetContext();
while(bGameExit == false)
{
// Event driven
switch(state)
{
case STATE_ON_WAIT:
ctx->Prepare(onWait);
ctx->Execute();
break;
case STATE_ON_RENDER:
ctx->Prepare(onRender);
ctx->Execute();
break;
// etc...
}
}
I may think there are some better methods because my code calls the script functions frequently.
Do you think what are better ways to do them or how to do in your project?
Give me your opinion
BTW, is there a game engine that is driven by AngelScript?
If it exists, I'll look into it.