aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-11-06 14:03:34 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-11-06 14:03:34 +0100
commitdb5a3668aa4b3919ee8dce7ed0872aa5707f80ff (patch)
tree6169d98300a2b26d84a85961a66e222a2ca2e5ca /src/crepe/api
parent64ca0a7ae147c7d98ff092e04d86468ace6ea2a1 (diff)
Added Doxygen comments
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/GameObject.h41
-rw-r--r--src/crepe/api/Transform.h25
2 files changed, 60 insertions, 6 deletions
diff --git a/src/crepe/api/GameObject.h b/src/crepe/api/GameObject.h
index 602f33c..246c4d4 100644
--- a/src/crepe/api/GameObject.h
+++ b/src/crepe/api/GameObject.h
@@ -7,15 +7,54 @@
namespace crepe {
+/**
+ * \brief Represents a GameObject
+ *
+ * This class represents a GameObject. The GameObject class is only used
+ * as an interface for the game programmer. The actual implementation is
+ * done in the ComponentManager.
+ */
class GameObject {
public:
+ /**
+ * This constructor creates a new GameObject. It creates a new
+ * Transform and Metadata component and adds them to the ComponentManager.
+ *
+ * \param id The id of the GameObject
+ * \param name The name of the GameObject
+ * \param tag The tag of the GameObject
+ * \param position The position of the GameObject
+ * \param rotation The rotation of the GameObject
+ * \param scale The scale of the GameObject
+ */
GameObject(uint32_t id, std::string name, std::string tag,
const Point & position, double rotation, double scale);
+ /**
+ * \brief Set the parent of this GameObject
+ *
+ * This method sets the parent of this GameObject. It sets the parent
+ * in the Metadata component of this GameObject and adds this GameObject
+ * to the children list of the parent GameObject.
+ *
+ * \param parent The parent GameObject
+ */
void set_parent(const GameObject & parent);
-
+ /**
+ * \brief Add a component to the GameObject
+ *
+ * This method adds a component to the GameObject. It forwards the
+ * arguments to the ComponentManager.
+ *
+ * \tparam T The type of the component
+ * \tparam Args The types of the arguments
+ * \param args The arguments to create the component
+ * \return The created component
+ */
template <typename T, typename... Args>
T & add_component(Args &&... args);
+public:
+ //! The id of the GameObject
uint32_t id;
};
diff --git a/src/crepe/api/Transform.h b/src/crepe/api/Transform.h
index 557061b..02125ef 100644
--- a/src/crepe/api/Transform.h
+++ b/src/crepe/api/Transform.h
@@ -8,15 +8,30 @@
namespace crepe {
+/**
+ * \brief Transform component
+ *
+ * This class represents the Transform component. It stores the position,
+ * rotation and scale of a GameObject.
+ */
class Transform : public Component {
- // FIXME: What's the difference between the `Point` and `Position`
- // classes/structs? How about we replace both with a universal `Vec2` that
- // works similar (or the same) as those found in GLSL?
-
public:
- Transform(uint32_t id, const Point &, double, double);
+ /**
+ * \param id The id of the GameObject this component belongs to
+ * \param point The position of the GameObject
+ * \param rot The rotation of the GameObject
+ * \param scale The scale of the GameObject
+ */
+ Transform(uint32_t id, const Point & point, double rot, double scale);
~Transform();
+ /**
+ * \brief Get the maximum number of instances for this component
+ *
+ * \return The maximum number of instances for this component
+ */
virtual int get_instances_max() const { return 1; }
+
+public:
//! Translation (shift)
Point position;
//! Rotation, in radians