![]() |
Calamity Engine 1.0.0
A cross-platform 2D game engine written in C++ and SDL3.
|
First off, if you're new to C++ maybe don't start out with my engine since I'm assuming that anyone who's reading this has some basic C++ knowledge. You should also probably be familiar with how a game engine like Godot or Unity works.
Generally, any project that's built with this framework should have this general structure:
Obviously this isn't 100% required, but I heavily recommend it.
By the way, the main way of navigating Calamity Engine's documentation is checking the documentation for a specific class you want info on. There are also the basic examples which you can find in the examples folder of the Calamity Engine repository or on the Calamity Engine website.
I use a library called cereal to serialize & deserialize nodes into/from JSON files or strings. You should probably read it's documentation to familiarize yourself with how it works. However, it should be simple enough.
Cereal does NOT like raw pointers, so, every node and component has to be a shared pointer (std::shared_ptr).
Let's take, for example, initializing the camera:
Any nodes that you want to be visible on screen have to be a child of the engine's root node.
Scripts are genuinely just classes in header files that extend components. Since scripts extend components you get convenient virtual functions such as: initialize, update, physics update and exit.
Since cereal doesn't like it when components don't have save and load functions, scripts have to include them. I decided that's probably the best way to go about it since developers (YOU) get more control over what's saved and what isn't.
Here is an example script for moving the camera using the input system:
And for this script to actually work, you have to add it to the camera node (in our case). So let's go back to the code we had earlier and update it to add the example script: