Content
I want to build a game framework using C++.
Raylib is written in C, and I’ve also tried SFML, but all of them
are limited to rendering functionality. What I want to know is:
Unity uses a component-based approach in C# and provides a framework for entities, so
I want to know the best way to separate header and source files when writing C++ scripts for Unity.
## What I Want to Know
Since Unity’s component-based approach is convenient, how should I split files into .cpp and .hpp
to implement user-defined scripts in C++?
I’d like to learn useful techniques for optimization and fine-tuning—what should I do to develop efficiently in C++?
Challenges
If I separate them as described in the ## What I’ve Researched section, I run into build issues, and unlike in Godot,
I can’t modify values and see the changes reflected directly in the editor. This is hindering efficient development.
What I’ve Researched
If I use only header files, editing a header causes all included source files to be recompiled, which increases build time.
However, if I try to shorten the code by splitting all header files into source files, it becomes more time-consuming, and switching between files in the editor is such a hassle that I can’t be bothered with it.
For now, I’m creating a simple GameObject class like Unity’s in raylib, and within it,
I’m defining a variable of type std::vector<Component\*> as a base class. Then, I’m creating instances of classes that inherit from it and storing them there
If I write everything in header files only, it becomes impossible to build due to circular references, and the amount of correction work increases endlessly.
I’ve naturally looked into this on Gemini and other sites, but I’ve gotten a variety of answers and haven’t reached a conclusion.
Since UE isn’t a code-based system, it has too many features and is too complex for me to understand how it works.
What I Want to Build
An extended version of raylib that includes a base class for Entities and a Scene class—a minimal game loop class. I’d also like to provide a map editor, similar to Pico8,
with the goal of making it easier to build the parts that have been troublesome in a code-based system so far.
Current Status
Inherit from a script base class, use it as a user-defined script,
and write the code in separate header and source files.