#define BZ_ENTRYPOINT #include BzObjectPool *nodePool = NULL; BzObjectPool *nodeStatePool = NULL; BzAIBTNode *printBT = NULL; BzAIBTStatus printAction(void *data) { bzLogInfo("Hello, world!"); return BZ_AIBT_FAIL; } bool init(int *game) { nodePool = bzObjectPoolCreate(&(BzObjectPoolDesc) { .objectSize = bzAIBTGetNodeSize(), }); nodeStatePool = bzObjectPoolCreate(&(BzObjectPoolDesc) { .objectSize = bzAIBTGetNodeStateSize() }); // for 1..5: // delay 1s // print "Hello, world!" printBT = bzAIBTMakeRoot(nodePool); BzAIBTNode *node = bzAIBTDecorRepeat(nodePool, printBT, 5); node = bzAIBTDecorDelay(nodePool, node, 1.0f); bzAIBTAction(nodePool, node, printAction); BzAIBTState state = bzAIBTCreateState(&(BzAIBTStateDesc) { .root = printBT, .pool = nodeStatePool, .userData = NULL }); BzAIBTStatus status = BZ_AIBT_RUNNING; i32 count = 0; while (status == BZ_AIBT_RUNNING) { status = bzAIBTExecute(&state, 0.2f); count++; } bzLogInfo("Iter: %d", count); bzObjectPoolDestroy(nodePool); bzObjectPoolDestroy(nodeStatePool); return true; } void render(float dt, int *game) { ClearBackground(WHITE); } bool bzMain(BzAppDesc *appDesc, int argc, const char **argv) { appDesc->init = (BzAppInitFunc) init; appDesc->render = (BzAppRenderFunc) render; init(NULL); return false; }