diff options
Diffstat (limited to 'src/crepe/api')
-rw-r--r-- | src/crepe/api/AI.cpp | 33 | ||||
-rw-r--r-- | src/crepe/api/AI.h | 12 | ||||
-rw-r--r-- | src/crepe/api/Animator.cpp | 6 | ||||
-rw-r--r-- | src/crepe/api/Animator.h | 6 | ||||
-rw-r--r-- | src/crepe/api/Asset.cpp | 2 | ||||
-rw-r--r-- | src/crepe/api/AudioSource.h | 2 | ||||
-rw-r--r-- | src/crepe/api/BoxCollider.cpp | 5 | ||||
-rw-r--r-- | src/crepe/api/BoxCollider.h | 5 | ||||
-rw-r--r-- | src/crepe/api/Camera.cpp | 5 | ||||
-rw-r--r-- | src/crepe/api/Camera.h | 6 | ||||
-rw-r--r-- | src/crepe/api/CircleCollider.cpp | 5 | ||||
-rw-r--r-- | src/crepe/api/CircleCollider.h | 5 | ||||
-rw-r--r-- | src/crepe/api/Color.cpp | 16 | ||||
-rw-r--r-- | src/crepe/api/Engine.cpp | 12 | ||||
-rw-r--r-- | src/crepe/api/Engine.h | 18 | ||||
-rw-r--r-- | src/crepe/api/GameObject.cpp | 12 | ||||
-rw-r--r-- | src/crepe/api/GameObject.h | 6 | ||||
-rw-r--r-- | src/crepe/api/ParticleEmitter.cpp | 7 | ||||
-rw-r--r-- | src/crepe/api/Scene.cpp | 6 | ||||
-rw-r--r-- | src/crepe/api/Scene.h | 7 | ||||
-rw-r--r-- | src/crepe/api/Script.h | 12 | ||||
-rw-r--r-- | src/crepe/api/Script.hpp | 11 | ||||
-rw-r--r-- | src/crepe/api/Text.cpp | 6 | ||||
-rw-r--r-- | src/crepe/api/Text.h | 6 | ||||
-rw-r--r-- | src/crepe/api/Transform.cpp | 2 |
25 files changed, 129 insertions, 84 deletions
diff --git a/src/crepe/api/AI.cpp b/src/crepe/api/AI.cpp index 2195249..2fedaf4 100644 --- a/src/crepe/api/AI.cpp +++ b/src/crepe/api/AI.cpp @@ -8,8 +8,9 @@ namespace crepe { AI::AI(game_object_id_t id, float max_force) : Component(id), max_force(max_force) {} -void AI::make_circle_path(float radius, const vec2 & center, float start_angle, - bool clockwise) { +void AI::make_circle_path( + float radius, const vec2 & center, float start_angle, bool clockwise +) { if (radius <= 0) { throw std::runtime_error("Radius must be greater than 0"); } @@ -25,19 +26,25 @@ void AI::make_circle_path(float radius, const vec2 & center, float start_angle, if (clockwise) { for (float i = start_angle; i < 2 * M_PI + start_angle; i += step) { - path.push_back(vec2{static_cast<float>(center.x + radius * cos(i)), - static_cast<float>(center.y + radius * sin(i))}); + path.push_back(vec2 { + static_cast<float>(center.x + radius * cos(i)), + static_cast<float>(center.y + radius * sin(i)) + }); } } else { for (float i = start_angle; i > start_angle - 2 * M_PI; i -= step) { - path.push_back(vec2{static_cast<float>(center.x + radius * cos(i)), - static_cast<float>(center.y + radius * sin(i))}); + path.push_back(vec2 { + static_cast<float>(center.x + radius * cos(i)), + static_cast<float>(center.y + radius * sin(i)) + }); } } } -void AI::make_oval_path(float radius_x, float radius_y, const vec2 & center, float start_angle, - bool clockwise, float rotation) { +void AI::make_oval_path( + float radius_x, float radius_y, const vec2 & center, float start_angle, bool clockwise, + float rotation +) { if (radius_x <= 0 && radius_y <= 0) { throw std::runtime_error("Radius must be greater than 0"); } @@ -73,14 +80,16 @@ void AI::make_oval_path(float radius_x, float radius_y, const vec2 & center, flo if (clockwise) { for (float i = start_angle; i < 2 * M_PI + start_angle; i += step) { - vec2 point = {static_cast<float>(center.x + radius_x * cos(i)), - static_cast<float>(center.y + radius_y * sin(i))}; + vec2 point + = {static_cast<float>(center.x + radius_x * cos(i)), + static_cast<float>(center.y + radius_y * sin(i))}; path.push_back(rotate_point(point, center)); } } else { for (float i = start_angle; i > start_angle - 2 * M_PI; i -= step) { - vec2 point = {static_cast<float>(center.x + radius_x * cos(i)), - static_cast<float>(center.y + radius_y * sin(i))}; + vec2 point + = {static_cast<float>(center.x + radius_x * cos(i)), + static_cast<float>(center.y + radius_y * sin(i))}; path.push_back(rotate_point(point, center)); } } diff --git a/src/crepe/api/AI.h b/src/crepe/api/AI.h index c780a91..bee11b3 100644 --- a/src/crepe/api/AI.h +++ b/src/crepe/api/AI.h @@ -70,8 +70,10 @@ public: * \param start_angle The start angle of the circle (in radians) * \param clockwise The direction of the circle */ - void make_circle_path(float radius, const vec2 & center = {0, 0}, float start_angle = 0, - bool clockwise = true); + void make_circle_path( + float radius, const vec2 & center = {0, 0}, float start_angle = 0, + bool clockwise = true + ); /** * \brief Make an oval path (for the path following behavior) * @@ -84,8 +86,10 @@ public: * \param clockwise The direction of the oval * \param rotation The rotation of the oval (in radians) */ - void make_oval_path(float radius_x, float radius_y, const vec2 & center = {0, 0}, - float start_angle = 0, bool clockwise = true, float rotation = 0); + void make_oval_path( + float radius_x, float radius_y, const vec2 & center = {0, 0}, float start_angle = 0, + bool clockwise = true, float rotation = 0 + ); public: //! The maximum force that can be applied to the entity (higher values will make the entity adjust faster) diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp index b7eefb8..c558d86 100644 --- a/src/crepe/api/Animator.cpp +++ b/src/crepe/api/Animator.cpp @@ -7,8 +7,10 @@ using namespace crepe; -Animator::Animator(game_object_id_t id, Sprite & spritesheet, const ivec2 & single_frame_size, - const uvec2 & grid_size, const Animator::Data & data) +Animator::Animator( + game_object_id_t id, Sprite & spritesheet, const ivec2 & single_frame_size, + const uvec2 & grid_size, const Animator::Data & data +) : Component(id), spritesheet(spritesheet), grid_size(grid_size), diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h index 5918800..102894d 100644 --- a/src/crepe/api/Animator.h +++ b/src/crepe/api/Animator.h @@ -83,8 +83,10 @@ public: * This constructor sets up the Animator with the given parameters, and initializes the * animation system. */ - Animator(game_object_id_t id, Sprite & spritesheet, const ivec2 & single_frame_size, - const uvec2 & grid_size, const Animator::Data & data); + Animator( + game_object_id_t id, Sprite & spritesheet, const ivec2 & single_frame_size, + const uvec2 & grid_size, const Animator::Data & data + ); ~Animator(); // dbg_trace public: diff --git a/src/crepe/api/Asset.cpp b/src/crepe/api/Asset.cpp index e148367..bab82e7 100644 --- a/src/crepe/api/Asset.cpp +++ b/src/crepe/api/Asset.cpp @@ -50,5 +50,5 @@ string Asset::whereami() const noexcept { bool Asset::operator==(const Asset & other) const noexcept { return this->src == other.src; } size_t std::hash<const Asset>::operator()(const Asset & asset) const noexcept { - return std::hash<string>{}(asset.get_path()); + return std::hash<string> {}(asset.get_path()); }; diff --git a/src/crepe/api/AudioSource.h b/src/crepe/api/AudioSource.h index b20e490..eaa56e8 100644 --- a/src/crepe/api/AudioSource.h +++ b/src/crepe/api/AudioSource.h @@ -68,7 +68,7 @@ private: typeof(loop) last_loop = loop; //! \} //! This source's voice handle - SoundHandle voice{}; + SoundHandle voice {}; }; } // namespace crepe diff --git a/src/crepe/api/BoxCollider.cpp b/src/crepe/api/BoxCollider.cpp index a893d41..f6b358d 100644 --- a/src/crepe/api/BoxCollider.cpp +++ b/src/crepe/api/BoxCollider.cpp @@ -4,7 +4,8 @@ using namespace crepe; -BoxCollider::BoxCollider(game_object_id_t game_object_id, const vec2 & dimensions, - const vec2 & offset) +BoxCollider::BoxCollider( + game_object_id_t game_object_id, const vec2 & dimensions, const vec2 & offset +) : Collider(game_object_id, offset), dimensions(dimensions) {} diff --git a/src/crepe/api/BoxCollider.h b/src/crepe/api/BoxCollider.h index d643e7f..229b90f 100644 --- a/src/crepe/api/BoxCollider.h +++ b/src/crepe/api/BoxCollider.h @@ -13,8 +13,9 @@ namespace crepe { */ class BoxCollider : public Collider { public: - BoxCollider(game_object_id_t game_object_id, const vec2 & dimensions, - const vec2 & offset = {0, 0}); + BoxCollider( + game_object_id_t game_object_id, const vec2 & dimensions, const vec2 & offset = {0, 0} + ); //! Width and height of the box collider vec2 dimensions; diff --git a/src/crepe/api/Camera.cpp b/src/crepe/api/Camera.cpp index 19a3296..b1466b5 100644 --- a/src/crepe/api/Camera.cpp +++ b/src/crepe/api/Camera.cpp @@ -6,8 +6,9 @@ using namespace crepe; -Camera::Camera(game_object_id_t id, const ivec2 & screen, const vec2 & viewport_size, - const Data & data) +Camera::Camera( + game_object_id_t id, const ivec2 & screen, const vec2 & viewport_size, const Data & data +) : Component(id), screen(screen), viewport_size(viewport_size), diff --git a/src/crepe/api/Camera.h b/src/crepe/api/Camera.h index 54d9a73..3191b04 100644 --- a/src/crepe/api/Camera.h +++ b/src/crepe/api/Camera.h @@ -44,8 +44,10 @@ public: * \param viewport_size is the view of the world in game units * \param data the camera component data */ - Camera(game_object_id_t id, const ivec2 & screen, const vec2 & viewport_size, - const Camera::Data & data); + Camera( + game_object_id_t id, const ivec2 & screen, const vec2 & viewport_size, + const Camera::Data & data + ); ~Camera(); // dbg_trace only public: diff --git a/src/crepe/api/CircleCollider.cpp b/src/crepe/api/CircleCollider.cpp index 90ab5e7..e72800c 100644 --- a/src/crepe/api/CircleCollider.cpp +++ b/src/crepe/api/CircleCollider.cpp @@ -2,7 +2,8 @@ using namespace crepe; -CircleCollider::CircleCollider(game_object_id_t game_object_id, float radius, - const vec2 & offset) +CircleCollider::CircleCollider( + game_object_id_t game_object_id, float radius, const vec2 & offset +) : Collider(game_object_id, offset), radius(radius) {} diff --git a/src/crepe/api/CircleCollider.h b/src/crepe/api/CircleCollider.h index 22da836..e6ad4fa 100644 --- a/src/crepe/api/CircleCollider.h +++ b/src/crepe/api/CircleCollider.h @@ -13,8 +13,9 @@ namespace crepe { */ class CircleCollider : public Collider { public: - CircleCollider(game_object_id_t game_object_id, float radius, - const vec2 & offset = {0, 0}); + CircleCollider( + game_object_id_t game_object_id, float radius, const vec2 & offset = {0, 0} + ); //! Radius of the circle collider. float radius; diff --git a/src/crepe/api/Color.cpp b/src/crepe/api/Color.cpp index 29bd77a..6858aa8 100644 --- a/src/crepe/api/Color.cpp +++ b/src/crepe/api/Color.cpp @@ -2,11 +2,11 @@ using namespace crepe; -const Color Color::WHITE{0xff, 0xff, 0xff}; -const Color Color::RED{0xff, 0x00, 0x00}; -const Color Color::GREEN{0x00, 0xff, 0x00}; -const Color Color::BLUE{0x00, 0x00, 0xff}; -const Color Color::BLACK{0x00, 0x00, 0x00}; -const Color Color::CYAN{0x00, 0xff, 0xff}; -const Color Color::YELLOW{0xff, 0xff, 0x00}; -const Color Color::MAGENTA{0xff, 0x00, 0xff}; +const Color Color::WHITE {0xff, 0xff, 0xff}; +const Color Color::RED {0xff, 0x00, 0x00}; +const Color Color::GREEN {0x00, 0xff, 0x00}; +const Color Color::BLUE {0x00, 0x00, 0xff}; +const Color Color::BLACK {0x00, 0x00, 0x00}; +const Color Color::CYAN {0x00, 0xff, 0xff}; +const Color Color::YELLOW {0xff, 0xff, 0x00}; +const Color Color::MAGENTA {0xff, 0x00, 0xff}; diff --git a/src/crepe/api/Engine.cpp b/src/crepe/api/Engine.cpp index 2e9d35a..cd9786b 100644 --- a/src/crepe/api/Engine.cpp +++ b/src/crepe/api/Engine.cpp @@ -46,8 +46,10 @@ void Engine::loop() { try { systems.fixed_update(); } catch (const exception & e) { - Log::logf(Log::Level::WARNING, - "Uncaught exception in fixed update function: {}\n", e.what()); + Log::logf( + Log::Level::WARNING, "Uncaught exception in fixed update function: {}\n", + e.what() + ); } timer.advance_fixed_elapsed_time(); } @@ -55,8 +57,10 @@ void Engine::loop() { try { systems.frame_update(); } catch (const exception & e) { - Log::logf(Log::Level::WARNING, "Uncaught exception in frame update function: {}\n", - e.what()); + Log::logf( + Log::Level::WARNING, "Uncaught exception in frame update function: {}\n", + e.what() + ); } timer.enforce_frame_rate(); } diff --git a/src/crepe/api/Engine.h b/src/crepe/api/Engine.h index 700a0cd..452a856 100644 --- a/src/crepe/api/Engine.h +++ b/src/crepe/api/Engine.h @@ -54,26 +54,26 @@ private: Mediator mediator; //! SystemManager - SystemManager system_manager{mediator}; + SystemManager system_manager {mediator}; //! SDLContext instance - SDLContext sdl_context{mediator}; + SDLContext sdl_context {mediator}; //! Resource manager instance - ResourceManager resource_manager{mediator}; + ResourceManager resource_manager {mediator}; //! Component manager instance - ComponentManager component_manager{mediator}; + ComponentManager component_manager {mediator}; //! Scene manager instance - SceneManager scene_manager{mediator}; + SceneManager scene_manager {mediator}; //! LoopTimerManager instance - LoopTimerManager loop_timer{mediator}; + LoopTimerManager loop_timer {mediator}; //! EventManager instance - EventManager event_manager{mediator}; + EventManager event_manager {mediator}; //! Save manager instance - SaveManager save_manager{mediator}; + SaveManager save_manager {mediator}; //! ReplayManager instance - ReplayManager replay_manager{mediator}; + ReplayManager replay_manager {mediator}; }; } // namespace crepe diff --git a/src/crepe/api/GameObject.cpp b/src/crepe/api/GameObject.cpp index 9b94cad..100e210 100644 --- a/src/crepe/api/GameObject.cpp +++ b/src/crepe/api/GameObject.cpp @@ -7,13 +7,15 @@ using namespace crepe; using namespace std; -GameObject::GameObject(Mediator & mediator, game_object_id_t id, const std::string & name, - const std::string & tag, const vec2 & position, double rotation, - double scale) +GameObject::GameObject( + Mediator & mediator, game_object_id_t id, const std::string & name, + const std::string & tag, const vec2 & position, double rotation, double scale +) : id(id), mediator(mediator), - transform(mediator.component_manager->add_component<Transform>(this->id, position, - rotation, scale)), + transform(mediator.component_manager->add_component<Transform>( + this->id, position, rotation, scale + )), metadata(mediator.component_manager->add_component<Metadata>(this->id, name, tag)) {} void GameObject::set_parent(const GameObject & parent) { diff --git a/src/crepe/api/GameObject.h b/src/crepe/api/GameObject.h index 572ce3a..043913a 100644 --- a/src/crepe/api/GameObject.h +++ b/src/crepe/api/GameObject.h @@ -30,8 +30,10 @@ private: * \param rotation The rotation of the GameObject * \param scale The scale of the GameObject */ - GameObject(Mediator & mediator, game_object_id_t id, const std::string & name, - const std::string & tag, const vec2 & position, double rotation, double scale); + GameObject( + Mediator & mediator, game_object_id_t id, const std::string & name, + const std::string & tag, const vec2 & position, double rotation, double scale + ); //! ComponentManager instances GameObject friend class ComponentManager; diff --git a/src/crepe/api/ParticleEmitter.cpp b/src/crepe/api/ParticleEmitter.cpp index 9a70334..341c1e2 100644 --- a/src/crepe/api/ParticleEmitter.cpp +++ b/src/crepe/api/ParticleEmitter.cpp @@ -4,8 +4,9 @@ using namespace crepe; using namespace std; -ParticleEmitter::ParticleEmitter(game_object_id_t game_object_id, const Sprite & sprite, - const Data & data) +ParticleEmitter::ParticleEmitter( + game_object_id_t game_object_id, const Sprite & sprite, const Data & data +) : Component(game_object_id), sprite(sprite), data(data) { @@ -15,7 +16,7 @@ ParticleEmitter::ParticleEmitter(game_object_id_t game_object_id, const Sprite & } unique_ptr<Component> ParticleEmitter::save() const { - return unique_ptr<Component>{new ParticleEmitter(*this)}; + return unique_ptr<Component> {new ParticleEmitter(*this)}; } void ParticleEmitter::restore(const Component & snapshot) { diff --git a/src/crepe/api/Scene.cpp b/src/crepe/api/Scene.cpp index ad729d2..84da7e8 100644 --- a/src/crepe/api/Scene.cpp +++ b/src/crepe/api/Scene.cpp @@ -4,8 +4,10 @@ using namespace crepe; SaveManager & Scene::get_save_manager() const { return mediator->save_manager; } -GameObject Scene::new_object(const std::string & name, const std::string & tag, - const vec2 & position, double rotation, double scale) { +GameObject Scene::new_object( + const std::string & name, const std::string & tag, const vec2 & position, double rotation, + double scale +) { // Forward the call to ComponentManager's new_object method return mediator->component_manager->new_object(name, tag, position, rotation, scale); } diff --git a/src/crepe/api/Scene.h b/src/crepe/api/Scene.h index d552a43..b50a0fc 100644 --- a/src/crepe/api/Scene.h +++ b/src/crepe/api/Scene.h @@ -69,9 +69,10 @@ public: SaveManager & get_save_manager() const; //! \copydoc ComponentManager::new_object - GameObject new_object(const std::string & name, const std::string & tag = "", - const vec2 & position = {0, 0}, double rotation = 0, - double scale = 1); + GameObject new_object( + const std::string & name, const std::string & tag = "", const vec2 & position = {0, 0}, + double rotation = 0, double scale = 1 + ); //! \copydoc ResourceManager::set_persistent void set_persistent(const Asset & asset, bool persistent); diff --git a/src/crepe/api/Script.h b/src/crepe/api/Script.h index bbee920..b000d9d 100644 --- a/src/crepe/api/Script.h +++ b/src/crepe/api/Script.h @@ -129,12 +129,14 @@ protected: void subscribe(const EventHandler<EventType> & callback); //! \copydoc EventManager::trigger_event template <typename EventType> - void trigger_event(const EventType & event = {}, - event_channel_t channel = EventManager::CHANNEL_ALL); + void trigger_event( + const EventType & event = {}, event_channel_t channel = EventManager::CHANNEL_ALL + ); //! \copydoc EventManager::queue_event template <typename EventType> - void queue_event(const EventType & event = {}, - event_channel_t channel = EventManager::CHANNEL_ALL); + void queue_event( + const EventType & event = {}, event_channel_t channel = EventManager::CHANNEL_ALL + ); //! \} /** @@ -179,7 +181,7 @@ protected: OptionalRef<Mediator> & mediator; replay(OptionalRef<Mediator> & mediator) : mediator(mediator) {} friend class Script; - } replay{mediator}; + } replay {mediator}; /** * \brief Utility function to retrieve the keyboard state diff --git a/src/crepe/api/Script.hpp b/src/crepe/api/Script.hpp index 4462a41..c7fa6ff 100644 --- a/src/crepe/api/Script.hpp +++ b/src/crepe/api/Script.hpp @@ -14,7 +14,8 @@ T & Script::get_component() const { RefVector<T> all_components = this->get_components<T>(); if (all_components.size() < 1) throw runtime_error( - format("Script: no component found with type = {}", typeid(T).name())); + format("Script: no component found with type = {}", typeid(T).name()) + ); return all_components.back().get(); } @@ -35,8 +36,9 @@ void Script::logf(std::format_string<Args...> fmt, Args &&... args) { } template <typename EventType> -void Script::subscribe_internal(const EventHandler<EventType> & callback, - event_channel_t channel) { +void Script::subscribe_internal( + const EventHandler<EventType> & callback, event_channel_t channel +) { EventManager & mgr = this->mediator->event_manager; subscription_t listener = mgr.subscribe<EventType>( [this, callback](const EventType & data) -> bool { @@ -54,7 +56,8 @@ void Script::subscribe_internal(const EventHandler<EventType> & callback, // call user-provided callback return callback(data); }, - channel); + channel + ); this->listeners.push_back(listener); } diff --git a/src/crepe/api/Text.cpp b/src/crepe/api/Text.cpp index 4a94180..b24f0ac 100644 --- a/src/crepe/api/Text.cpp +++ b/src/crepe/api/Text.cpp @@ -2,8 +2,10 @@ using namespace crepe; -Text::Text(game_object_id_t id, const vec2 & dimensions, const vec2 & offset, - const std::string & font_family, const Data & data, const std::string & text) +Text::Text( + game_object_id_t id, const vec2 & dimensions, const vec2 & offset, + const std::string & font_family, const Data & data, const std::string & text +) : UIObject(id, dimensions, offset), text(text), data(data), diff --git a/src/crepe/api/Text.h b/src/crepe/api/Text.h index da40141..0289b85 100644 --- a/src/crepe/api/Text.h +++ b/src/crepe/api/Text.h @@ -48,8 +48,10 @@ public: * \param data Data struct containing extra text parameters. * \param font Optional font asset that can be passed or left empty. */ - Text(game_object_id_t id, const vec2 & dimensions, const vec2 & offset, - const std::string & font_family, const Data & data, const std::string & text = ""); + Text( + game_object_id_t id, const vec2 & dimensions, const vec2 & offset, + const std::string & font_family, const Data & data, const std::string & text = "" + ); //! Label text. std::string text = ""; diff --git a/src/crepe/api/Transform.cpp b/src/crepe/api/Transform.cpp index fcfce14..b70174c 100644 --- a/src/crepe/api/Transform.cpp +++ b/src/crepe/api/Transform.cpp @@ -14,7 +14,7 @@ Transform::Transform(game_object_id_t id, const vec2 & point, double rotation, d } unique_ptr<Component> Transform::save() const { - return unique_ptr<Component>{new Transform(*this)}; + return unique_ptr<Component> {new Transform(*this)}; } void Transform::restore(const Component & snapshot) { |