diff options
author | max-001 <maxsmits21@kpnmail.nl> | 2024-11-20 11:42:23 +0100 |
---|---|---|
committer | max-001 <maxsmits21@kpnmail.nl> | 2024-11-20 11:42:23 +0100 |
commit | e585e01b625fcdbc00709c1bbade1b542b1f6139 (patch) | |
tree | 7ab095da8955a4299110a98a3b4f11de2087edde /src | |
parent | 0476a8e9dbe7afb422862f7b1c15aaed7f3c416e (diff) |
Added Doxygen comments/explanation for GameObjects and Scenes
Diffstat (limited to 'src')
-rw-r--r-- | src/crepe/api/Scene.h | 14 | ||||
-rw-r--r-- | src/crepe/api/SceneManager.h | 10 | ||||
-rw-r--r-- | src/doc/feature/gameobject.dox | 18 | ||||
-rw-r--r-- | src/doc/feature/scene.dox | 60 |
4 files changed, 102 insertions, 0 deletions
diff --git a/src/crepe/api/Scene.h b/src/crepe/api/Scene.h index 0e516b6..6647135 100644 --- a/src/crepe/api/Scene.h +++ b/src/crepe/api/Scene.h @@ -7,19 +7,33 @@ namespace crepe { class SceneManager; class ComponentManager; +/** + * \brief Represents a Scene + * + * This class represents a Scene. The Scene class is only used as an interface for the game + * programmer. + */ class Scene { protected: + /** + * \param mgr Reference to the ComponentManager + * \param name Name of the scene + */ Scene(ComponentManager & mgr, const std::string & name); + //! SceneManager instances Scene friend class SceneManager; public: virtual ~Scene() = default; public: + //! Load the scene virtual void load_scene() = 0; + //! The scene name const std::string name; protected: + //! Reference to the ComponentManager ComponentManager & component_manager; }; diff --git a/src/crepe/api/SceneManager.h b/src/crepe/api/SceneManager.h index e854794..16d6004 100644 --- a/src/crepe/api/SceneManager.h +++ b/src/crepe/api/SceneManager.h @@ -10,8 +10,15 @@ namespace crepe { class ComponentManager; +/** + * \brief Manages scenes + * + * This class manages scenes. It can add new scenes and load them. It also manages the current scene + * and the next scene. + */ class SceneManager { public: + //! \param mgr Reference to the ComponentManager SceneManager(ComponentManager & mgr); public: @@ -35,8 +42,11 @@ public: void load_next_scene(); private: + //! Vector of scenes std::vector<std::unique_ptr<Scene>> scenes; + //! Next scene to load std::string next_scene; + //! Reference to the ComponentManager ComponentManager & component_manager; }; diff --git a/src/doc/feature/gameobject.dox b/src/doc/feature/gameobject.dox new file mode 100644 index 0000000..603c98d --- /dev/null +++ b/src/doc/feature/gameobject.dox @@ -0,0 +1,18 @@ +// vim:ft=doxygen +namespace crepe { +/** + +\defgroup feature_gameobject GameObjects +\ingroup feature +\brief GameObject to create a Scene + +GameObjects are the fundamental building blocks of a Scene. They represent entities +in the game world and can have various components attached to them to define their +behavior and properties. GameObjects can be created, and modified within the +Scene, allowing for a flexible and dynamic game environment. + +\see Component +\see Scene + +*/ +} diff --git a/src/doc/feature/scene.dox b/src/doc/feature/scene.dox new file mode 100644 index 0000000..50f5ebd --- /dev/null +++ b/src/doc/feature/scene.dox @@ -0,0 +1,60 @@ +// vim:ft=doxygen +namespace crepe { +/** + +\defgroup feature_scene Scenes +\ingroup feature +\brief User-defined scenes + +Scenes can be used to implement game environments, and allow arbitrary game objects to be organized +as part of the game structure. Scenes are implemented as derivative classes of Scene, which are +added to the game using the SceneManager. Scenes describe the start of a Scene and cannot modify +GameObject during runtime of a Scene (use Scripting for this purpose). + +\see SceneManager +\see GameObject +\see Script +\see Scene + +\par Example + +This example demonstrates how to define and add scenes to a scene manager in the `crepe` framework. +Two concrete scene classes, `ConcreteScene1` and `ConcreteScene2`, are derived from the base `Scene` class. +Each scene class overrides the `load_scene` method to create and initialize game objects specific to the scene. +Finally, the scenes are added to the scene manager. + +```cpp +using namespace crepe; + +class ConcreteScene1 : public Scene { +public: + using Scene::Scene; + + void load_scene() { + auto & mgr = this->component_manager; + GameObject object1 = mgr.new_object("scene_1", "tag_scene_1", Vector2{0, 0}, 0, 1); + GameObject object2 = mgr.new_object("scene_1", "tag_scene_1", Vector2{1, 0}, 0, 1); + GameObject object3 = mgr.new_object("scene_1", "tag_scene_1", Vector2{2, 0}, 0, 1); + } +}; + +class ConcreteScene2 : public Scene { +public: + using Scene::Scene; + + void load_scene() { + auto & mgr = this->component_manager; + GameObject object1 = mgr.new_object("scene_2", "tag_scene_2", Vector2{0, 0}, 0, 1); + GameObject object2 = mgr.new_object("scene_2", "tag_scene_2", Vector2{0, 1}, 0, 1); + GameObject object3 = mgr.new_object("scene_2", "tag_scene_2", Vector2{0, 2}, 0, 1); + GameObject object4 = mgr.new_object("scene_2", "tag_scene_2", Vector2{0, 3}, 0, 1); + } +}; + +// Add the scenes to the scene manager +scene_mgr.add_scene<ConcreteScene1>("scene1"); +scene_mgr.add_scene<ConcreteScene2>("scene2"); +``` + +*/ +} |