0 votes

How to integrate exsiting c++ project in godot 2D?
for some game already has some written code , rewrite it would be a huge task.
Since godot has plugin, how to use it with existing code.

This kind of project usually has a whole game logic ,and game loop like
loop {
DealwithInput
updateGame()
Draw()
}
we just want godot do the input , load texture and draw .
updateGame logic is in old code.
For the draw part, just need a node that display sprite each loop.
the sprite attribute like position is update in old c/c++ code

Does anyone has any idea how to do this ?

in Engine by (16 points)

2 Answers

0 votes

There are many existing project , they may need this feature too.
redo everything from start , it is a big task

by (16 points)
+1 vote

Godot's SceneTree manages the game loop (input, update, draw).

You can have a single Node in the tree that manages the data or port it to the Godot way and make many nodes for different tasks (in gdscript and gdnative if needed).

For a more tight integration, look if you can modify the engine and make your own MainLoop.

Check
https://github.com/godotengine/godot/blob/3.0/scene/main/scene_tree.cpp

And
https://github.com/godotengine/godot/blob/3.0/core/os/main_loop.cpp

by (7,860 points)

in my opinion ,

make a node for the main game
run the old c logic code in an independent thread , make 2 pipe.
Pipe1 to get the input from godot.
Pipe2 to push the display sprite each frame to godot.
Godot just do rendering in this node.

For other menu, setting, ui etc, make other node, use the godot way.

Is it possible ?
And how to make this main game

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.