aboutsummaryrefslogtreecommitdiff
path: root/src/crepe
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe')
-rw-r--r--src/crepe/Particle.cpp5
-rw-r--r--src/crepe/Particle.h4
-rw-r--r--src/crepe/api/AI.cpp33
-rw-r--r--src/crepe/api/AI.h12
-rw-r--r--src/crepe/api/Animator.cpp6
-rw-r--r--src/crepe/api/Animator.h6
-rw-r--r--src/crepe/api/Asset.cpp2
-rw-r--r--src/crepe/api/AudioSource.h2
-rw-r--r--src/crepe/api/BoxCollider.cpp5
-rw-r--r--src/crepe/api/BoxCollider.h5
-rw-r--r--src/crepe/api/Camera.cpp5
-rw-r--r--src/crepe/api/Camera.h6
-rw-r--r--src/crepe/api/CircleCollider.cpp5
-rw-r--r--src/crepe/api/CircleCollider.h5
-rw-r--r--src/crepe/api/Color.cpp16
-rw-r--r--src/crepe/api/Engine.cpp12
-rw-r--r--src/crepe/api/Engine.h18
-rw-r--r--src/crepe/api/GameObject.cpp12
-rw-r--r--src/crepe/api/GameObject.h6
-rw-r--r--src/crepe/api/ParticleEmitter.cpp7
-rw-r--r--src/crepe/api/Scene.cpp6
-rw-r--r--src/crepe/api/Scene.h7
-rw-r--r--src/crepe/api/Script.h12
-rw-r--r--src/crepe/api/Script.hpp11
-rw-r--r--src/crepe/api/Text.cpp6
-rw-r--r--src/crepe/api/Text.h6
-rw-r--r--src/crepe/api/Transform.cpp2
-rw-r--r--src/crepe/facade/FontFacade.cpp5
-rw-r--r--src/crepe/facade/SDLContext.cpp61
-rw-r--r--src/crepe/facade/SDLContext.h7
-rw-r--r--src/crepe/manager/ComponentManager.cpp22
-rw-r--r--src/crepe/manager/ComponentManager.h7
-rw-r--r--src/crepe/manager/ComponentManager.hpp20
-rw-r--r--src/crepe/manager/EventManager.h4
-rw-r--r--src/crepe/manager/EventManager.hpp14
-rw-r--r--src/crepe/manager/LoopTimerManager.cpp6
-rw-r--r--src/crepe/manager/LoopTimerManager.h12
-rw-r--r--src/crepe/manager/ResourceManager.hpp13
-rw-r--r--src/crepe/manager/SceneManager.cpp10
-rw-r--r--src/crepe/manager/SystemManager.hpp10
-rw-r--r--src/crepe/system/AISystem.cpp21
-rw-r--r--src/crepe/system/CollisionSystem.cpp81
-rw-r--r--src/crepe/system/CollisionSystem.h40
-rw-r--r--src/crepe/system/InputSystem.cpp36
-rw-r--r--src/crepe/system/InputSystem.h21
-rw-r--r--src/crepe/system/ParticleSystem.cpp17
-rw-r--r--src/crepe/system/RenderSystem.cpp6
-rw-r--r--src/crepe/system/ScriptSystem.cpp5
-rw-r--r--src/crepe/util/dbg.h11
49 files changed, 382 insertions, 269 deletions
diff --git a/src/crepe/Particle.cpp b/src/crepe/Particle.cpp
index b340826..27fa97f 100644
--- a/src/crepe/Particle.cpp
+++ b/src/crepe/Particle.cpp
@@ -2,8 +2,9 @@
using namespace crepe;
-void Particle::reset(unsigned int lifespan, const vec2 & position, const vec2 & velocity,
- float angle) {
+void Particle::reset(
+ unsigned int lifespan, const vec2 & position, const vec2 & velocity, float angle
+) {
// Initialize the particle state
this->time_in_life = 0;
this->lifespan = lifespan;
diff --git a/src/crepe/Particle.h b/src/crepe/Particle.h
index ee0cd66..c013de5 100644
--- a/src/crepe/Particle.h
+++ b/src/crepe/Particle.h
@@ -41,8 +41,8 @@ public:
* \param velocity The initial velocity of the particle.
* \param angle The angle of the particle's trajectory or orientation.
*/
- void reset(unsigned int lifespan, const vec2 & position, const vec2 & velocity,
- float angle);
+ void
+ reset(unsigned int lifespan, const vec2 & position, const vec2 & velocity, float angle);
/**
* \brief Updates the particle's state.
*
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) {
diff --git a/src/crepe/facade/FontFacade.cpp b/src/crepe/facade/FontFacade.cpp
index 87f95ab..e284f5a 100644
--- a/src/crepe/facade/FontFacade.cpp
+++ b/src/crepe/facade/FontFacade.cpp
@@ -20,8 +20,9 @@ Asset FontFacade::get_font_asset(const string & font_family) {
= FcNameParse(reinterpret_cast<const FcChar8 *>(font_family.c_str()));
if (raw_pattern == NULL) throw runtime_error("Failed to create font pattern.");
- unique_ptr<FcPattern, function<void(FcPattern *)>> pattern{
- raw_pattern, [](FcPattern * p) { FcPatternDestroy(p); }};
+ unique_ptr<FcPattern, function<void(FcPattern *)>> pattern {
+ raw_pattern, [](FcPattern * p) { FcPatternDestroy(p); }
+ };
FcConfig * config = FcConfigGetCurrent();
if (config == NULL) throw runtime_error("Failed to get current Fontconfig configuration.");
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp
index 64c1fe2..859f966 100644
--- a/src/crepe/facade/SDLContext.cpp
+++ b/src/crepe/facade/SDLContext.cpp
@@ -41,9 +41,10 @@ SDLContext::SDLContext(Mediator & mediator) {
}
auto & cfg = Config::get_instance().window_settings;
- SDL_Window * tmp_window
- = SDL_CreateWindow(cfg.window_title.c_str(), SDL_WINDOWPOS_CENTERED,
- SDL_WINDOWPOS_CENTERED, cfg.default_size.x, cfg.default_size.y, 0);
+ SDL_Window * tmp_window = SDL_CreateWindow(
+ cfg.window_title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
+ cfg.default_size.x, cfg.default_size.y, 0
+ );
if (!tmp_window) {
throw runtime_error(format("SDLContext: SDL_Window error: {}", SDL_GetError()));
}
@@ -52,8 +53,8 @@ SDLContext::SDLContext(Mediator & mediator) {
SDL_Renderer * tmp_renderer
= SDL_CreateRenderer(this->game_window.get(), -1, SDL_RENDERER_ACCELERATED);
if (!tmp_renderer) {
- throw runtime_error(
- format("SDLContext: SDL_CreateRenderer error: {}", SDL_GetError()));
+ throw runtime_error(format("SDLContext: SDL_CreateRenderer error: {}", SDL_GetError())
+ );
}
this->game_renderer
@@ -108,7 +109,7 @@ const keyboard_state_t & SDLContext::get_keyboard_state() {
MouseButton SDLContext::sdl_to_mousebutton(Uint8 sdl_button) {
static const std::array<MouseButton, 5> MOUSE_BUTTON_LOOKUP_TABLE = [] {
- std::array<MouseButton, 5> table{};
+ std::array<MouseButton, 5> table {};
table.fill(MouseButton::NONE);
table[SDL_BUTTON_LEFT] = MouseButton::LEFT_MOUSE;
@@ -164,7 +165,7 @@ SDL_FRect SDLContext::get_dst_rect(const DestinationRectangleData & ctx) const {
- size / 2 + cam_aux_data.bar_size;
}
- return SDL_FRect{
+ return SDL_FRect {
.x = screen_pos.x,
.y = screen_pos.y,
.w = size.x,
@@ -188,7 +189,7 @@ void SDLContext::draw(const RenderContext & ctx) {
srcrect_ptr = &srcrect;
}
- SDL_FRect dstrect = this->get_dst_rect(SDLContext::DestinationRectangleData{
+ SDL_FRect dstrect = this->get_dst_rect(SDLContext::DestinationRectangleData {
.sprite = ctx.sprite,
.texture = ctx.texture,
.pos = ctx.pos,
@@ -198,8 +199,10 @@ void SDLContext::draw(const RenderContext & ctx) {
double angle = ctx.angle + data.angle_offset;
this->set_color_texture(ctx.texture, ctx.sprite.data.color);
- SDL_RenderCopyExF(this->game_renderer.get(), ctx.texture.get_img(), srcrect_ptr, &dstrect,
- angle, NULL, render_flip);
+ SDL_RenderCopyExF(
+ this->game_renderer.get(), ctx.texture.get_img(), srcrect_ptr, &dstrect, angle, NULL,
+ render_flip
+ );
}
void SDLContext::draw_text(const RenderText & data) {
@@ -210,7 +213,7 @@ void SDLContext::draw_text(const RenderText & data) {
std::unique_ptr<SDL_Surface, std::function<void(SDL_Surface *)>> font_surface;
std::unique_ptr<SDL_Texture, std::function<void(SDL_Texture *)>> font_texture;
- SDL_Color color{
+ SDL_Color color {
.r = text.data.text_color.r,
.g = text.data.text_color.g,
.b = text.data.text_color.b,
@@ -232,20 +235,21 @@ void SDLContext::draw_text(const RenderText & data) {
= {tmp_font_texture, [](SDL_Texture * texture) { SDL_DestroyTexture(texture); }};
vec2 size = text.dimensions * cam_aux_data.render_scale * data.transform.scale;
- vec2 screen_pos
- = (absoluut_pos - cam_aux_data.cam_pos + (cam_aux_data.zoomed_viewport) / 2)
- * cam_aux_data.render_scale
- - size / 2 + cam_aux_data.bar_size;
+ vec2 screen_pos = (absoluut_pos - cam_aux_data.cam_pos + (cam_aux_data.zoomed_viewport) / 2
+ ) * cam_aux_data.render_scale
+ - size / 2 + cam_aux_data.bar_size;
- SDL_FRect dstrect{
+ SDL_FRect dstrect {
.x = screen_pos.x,
.y = screen_pos.y,
.w = size.x,
.h = size.y,
};
- SDL_RenderCopyExF(this->game_renderer.get(), font_texture.get(), NULL, &dstrect,
- data.transform.rotation, NULL, SDL_FLIP_NONE);
+ SDL_RenderCopyExF(
+ this->game_renderer.get(), font_texture.get(), NULL, &dstrect, data.transform.rotation,
+ NULL, SDL_FLIP_NONE
+ );
}
void SDLContext::update_camera_view(const Camera & cam, const vec2 & new_pos) {
@@ -291,8 +295,10 @@ void SDLContext::update_camera_view(const Camera & cam, const vec2 & new_pos) {
render_scale.x = render_scale.y = scale;
}
- SDL_SetRenderDrawColor(this->game_renderer.get(), cam_data.bg_color.r, cam_data.bg_color.g,
- cam_data.bg_color.b, cam_data.bg_color.a);
+ SDL_SetRenderDrawColor(
+ this->game_renderer.get(), cam_data.bg_color.r, cam_data.bg_color.g,
+ cam_data.bg_color.b, cam_data.bg_color.a
+ );
SDL_Rect bg = {
.x = 0,
@@ -427,11 +433,12 @@ std::vector<EventData> SDLContext::get_events() {
return event_list;
}
-void SDLContext::handle_window_event(const SDL_WindowEvent & window_event,
- std::vector<EventData> & event_list) {
+void SDLContext::handle_window_event(
+ const SDL_WindowEvent & window_event, std::vector<EventData> & event_list
+) {
switch (window_event.event) {
case SDL_WINDOWEVENT_EXPOSED:
- event_list.push_back(EventData{EventType::WINDOW_EXPOSE});
+ event_list.push_back(EventData {EventType::WINDOW_EXPOSE});
break;
case SDL_WINDOWEVENT_RESIZED:
event_list.push_back(EventData{
@@ -455,16 +462,16 @@ void SDLContext::handle_window_event(const SDL_WindowEvent & window_event,
break;
case SDL_WINDOWEVENT_MINIMIZED:
- event_list.push_back(EventData{EventType::WINDOW_MINIMIZE});
+ event_list.push_back(EventData {EventType::WINDOW_MINIMIZE});
break;
case SDL_WINDOWEVENT_MAXIMIZED:
- event_list.push_back(EventData{EventType::WINDOW_MAXIMIZE});
+ event_list.push_back(EventData {EventType::WINDOW_MAXIMIZE});
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
- event_list.push_back(EventData{EventType::WINDOW_FOCUS_GAIN});
+ event_list.push_back(EventData {EventType::WINDOW_FOCUS_GAIN});
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
- event_list.push_back(EventData{EventType::WINDOW_FOCUS_LOST});
+ event_list.push_back(EventData {EventType::WINDOW_FOCUS_LOST});
break;
}
}
diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h
index e570073..bc118f9 100644
--- a/src/crepe/facade/SDLContext.h
+++ b/src/crepe/facade/SDLContext.h
@@ -116,8 +116,9 @@ public:
* This method checks if any window events are triggered and adds them to the event_list.
*
*/
- void handle_window_event(const SDL_WindowEvent & window_event,
- std::vector<EventData> & event_list);
+ void handle_window_event(
+ const SDL_WindowEvent & window_event, std::vector<EventData> & event_list
+ );
/**
* \brief Converts an SDL scan code to the custom Keycode type.
*
@@ -254,7 +255,7 @@ private:
private:
//! instance of the font_facade
- FontFacade font_facade{};
+ FontFacade font_facade {};
public:
/**
diff --git a/src/crepe/manager/ComponentManager.cpp b/src/crepe/manager/ComponentManager.cpp
index 745ddae..245419d 100644
--- a/src/crepe/manager/ComponentManager.cpp
+++ b/src/crepe/manager/ComponentManager.cpp
@@ -46,14 +46,16 @@ void ComponentManager::delete_all_components() {
this->next_id = 0;
}
-GameObject ComponentManager::new_object(const string & name, const string & tag,
- const vec2 & position, double rotation, double scale) {
+GameObject ComponentManager::new_object(
+ const string & name, const string & tag, const vec2 & position, double rotation,
+ double scale
+) {
// Find the first available id (taking persistent objects into account)
while (this->persistent[this->next_id]) {
this->next_id++;
}
- GameObject object{this->mediator, this->next_id, name, tag, position, rotation, scale};
+ GameObject object {this->mediator, this->next_id, name, tag, position, rotation, scale};
this->next_id++;
return object;
@@ -64,23 +66,25 @@ void ComponentManager::set_persistent(game_object_id_t id, bool persistent) {
}
set<game_object_id_t> ComponentManager::get_objects_by_name(const string & name) const {
- return this->get_objects_by_predicate<Metadata>(
- [name](const Metadata & data) { return data.name == name; });
+ return this->get_objects_by_predicate<Metadata>([name](const Metadata & data) {
+ return data.name == name;
+ });
}
set<game_object_id_t> ComponentManager::get_objects_by_tag(const string & tag) const {
- return this->get_objects_by_predicate<Metadata>(
- [tag](const Metadata & data) { return data.tag == tag; });
+ return this->get_objects_by_predicate<Metadata>([tag](const Metadata & data) {
+ return data.tag == tag;
+ });
}
ComponentManager::Snapshot ComponentManager::save() {
- Snapshot snapshot{};
+ Snapshot snapshot {};
for (const auto & [type, by_id_index] : this->components) {
for (game_object_id_t id = 0; id < by_id_index.size(); id++) {
const auto & components = by_id_index[id];
for (size_t index = 0; index < components.size(); index++) {
const Component & component = *components[index];
- snapshot.components.push_back(SnapshotComponent{
+ snapshot.components.push_back(SnapshotComponent {
.type = type,
.id = id,
.index = index,
diff --git a/src/crepe/manager/ComponentManager.h b/src/crepe/manager/ComponentManager.h
index c3a5b4a..2eb1f7e 100644
--- a/src/crepe/manager/ComponentManager.h
+++ b/src/crepe/manager/ComponentManager.h
@@ -38,9 +38,10 @@ public:
*
* \note This method automatically assigns a new entity ID
*/
- 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
+ );
public:
/**
diff --git a/src/crepe/manager/ComponentManager.hpp b/src/crepe/manager/ComponentManager.hpp
index 9e70865..6d32edb 100644
--- a/src/crepe/manager/ComponentManager.hpp
+++ b/src/crepe/manager/ComponentManager.hpp
@@ -11,8 +11,10 @@ template <class T, typename... Args>
T & ComponentManager::add_component(game_object_id_t id, Args &&... args) {
using namespace std;
- static_assert(is_base_of<Component, T>::value,
- "add_component must recieve a derivative class of Component");
+ static_assert(
+ is_base_of<Component, T>::value,
+ "add_component must recieve a derivative class of Component"
+ );
// Determine the type of T (this is used as the key of the unordered_map<>)
type_index type = typeid(T);
@@ -40,8 +42,8 @@ T & ComponentManager::add_component(game_object_id_t id, Args &&... args) {
// Check if the vector size is not greater than get_instances_max
int max_instances = instance->get_instances_max();
if (max_instances != -1 && components[type][id].size() >= max_instances) {
- throw std::runtime_error(
- "Exceeded maximum number of instances for this component type");
+ throw std::runtime_error("Exceeded maximum number of instances for this component type"
+ );
}
// store its unique_ptr in the vector<>
@@ -95,8 +97,10 @@ template <typename T>
RefVector<T> ComponentManager::get_components_by_id(game_object_id_t id) const {
using namespace std;
- static_assert(is_base_of<Component, T>::value,
- "get_components_by_id must recieve a derivative class of Component");
+ static_assert(
+ is_base_of<Component, T>::value,
+ "get_components_by_id must recieve a derivative class of Component"
+ );
type_index type = typeid(T);
if (!this->components.contains(type)) return {};
@@ -170,8 +174,8 @@ ComponentManager::get_objects_by_predicate(const std::function<bool(const T &)>
}
template <typename T>
-RefVector<T>
-ComponentManager::get_components_by_ids(const std::set<game_object_id_t> & ids) const {
+RefVector<T> ComponentManager::get_components_by_ids(const std::set<game_object_id_t> & ids
+) const {
using namespace std;
RefVector<T> out = {};
diff --git a/src/crepe/manager/EventManager.h b/src/crepe/manager/EventManager.h
index 0a57fb1..5766a0c 100644
--- a/src/crepe/manager/EventManager.h
+++ b/src/crepe/manager/EventManager.h
@@ -49,8 +49,8 @@ public:
* \return A unique subscription ID associated with the registered callback.
*/
template <typename EventType>
- subscription_t subscribe(const EventHandler<EventType> & callback,
- event_channel_t channel = CHANNEL_ALL);
+ subscription_t
+ subscribe(const EventHandler<EventType> & callback, event_channel_t channel = CHANNEL_ALL);
/**
* \brief Unsubscribe a previously registered callback.
diff --git a/src/crepe/manager/EventManager.hpp b/src/crepe/manager/EventManager.hpp
index b2090d0..1f44943 100644
--- a/src/crepe/manager/EventManager.hpp
+++ b/src/crepe/manager/EventManager.hpp
@@ -5,22 +5,24 @@
namespace crepe {
template <typename EventType>
-subscription_t EventManager::subscribe(const EventHandler<EventType> & callback,
- event_channel_t channel) {
+subscription_t
+EventManager::subscribe(const EventHandler<EventType> & callback, event_channel_t channel) {
subscription_counter++;
std::type_index event_type = typeid(EventType);
std::unique_ptr<EventHandlerWrapper<EventType>> handler
= std::make_unique<EventHandlerWrapper<EventType>>(callback);
std::vector<CallbackEntry> & handlers = this->subscribers[event_type];
- handlers.emplace_back(CallbackEntry{
- .callback = std::move(handler), .channel = channel, .id = subscription_counter});
+ handlers.emplace_back(CallbackEntry {
+ .callback = std::move(handler), .channel = channel, .id = subscription_counter
+ });
return subscription_counter;
}
template <typename EventType>
void EventManager::queue_event(const EventType & event, event_channel_t channel) {
- static_assert(std::is_base_of<Event, EventType>::value,
- "EventType must derive from Event");
+ static_assert(
+ std::is_base_of<Event, EventType>::value, "EventType must derive from Event"
+ );
this->events_queue.push_back(QueueEntry{
// unique_ptr w/ custom destructor implementation is used because the base Event interface
// can't be polymorphic (= have default virtual destructor)
diff --git a/src/crepe/manager/LoopTimerManager.cpp b/src/crepe/manager/LoopTimerManager.cpp
index e78f92f..b4cd07f 100644
--- a/src/crepe/manager/LoopTimerManager.cpp
+++ b/src/crepe/manager/LoopTimerManager.cpp
@@ -17,9 +17,9 @@ LoopTimerManager::LoopTimerManager(Mediator & mediator) : Manager(mediator) {
void LoopTimerManager::start() {
this->last_frame_time = std::chrono::steady_clock::now();
- this->elapsed_time = elapsed_time_t{0};
- this->elapsed_fixed_time = elapsed_time_t{0};
- this->delta_time = duration_t{0};
+ this->elapsed_time = elapsed_time_t {0};
+ this->elapsed_fixed_time = elapsed_time_t {0};
+ this->delta_time = duration_t {0};
}
void LoopTimerManager::update() {
diff --git a/src/crepe/manager/LoopTimerManager.h b/src/crepe/manager/LoopTimerManager.h
index 2f1e6b6..279d6b2 100644
--- a/src/crepe/manager/LoopTimerManager.h
+++ b/src/crepe/manager/LoopTimerManager.h
@@ -157,17 +157,17 @@ private:
//! Time scale for speeding up or slowing down the game (0 = pause, < 1 = slow down, 1 = normal speed, > 1 = speed up).
float time_scale = 1;
//! Maximum delta time in seconds to avoid large jumps.
- duration_t maximum_delta_time{0.25};
+ duration_t maximum_delta_time {0.25};
//! Delta time for the current frame in seconds.
- duration_t delta_time{0.0};
+ duration_t delta_time {0.0};
//! Target time per frame in seconds
- duration_t frame_target_time{1.0 / target_fps};
+ duration_t frame_target_time {1.0 / target_fps};
//! Fixed delta time for fixed updates in seconds.
- duration_t fixed_delta_time{1.0 / 50.0};
+ duration_t fixed_delta_time {1.0 / 50.0};
//! Total elapsed game time in microseconds.
- elapsed_time_t elapsed_time{0};
+ elapsed_time_t elapsed_time {0};
//! Total elapsed time for fixed updates in microseconds.
- elapsed_time_t elapsed_fixed_time{0};
+ elapsed_time_t elapsed_fixed_time {0};
typedef std::chrono::steady_clock::time_point time_point_t;
//! Time of the last frame.
diff --git a/src/crepe/manager/ResourceManager.hpp b/src/crepe/manager/ResourceManager.hpp
index cf5c949..4ca6be0 100644
--- a/src/crepe/manager/ResourceManager.hpp
+++ b/src/crepe/manager/ResourceManager.hpp
@@ -9,17 +9,20 @@ namespace crepe {
template <typename T>
T & ResourceManager::get(const Asset & asset) {
using namespace std;
- static_assert(is_base_of<Resource, T>::value,
- "cache must recieve a derivative class of Resource");
+ static_assert(
+ is_base_of<Resource, T>::value, "cache must recieve a derivative class of Resource"
+ );
CacheEntry & entry = this->get_entry(asset);
if (entry.resource == nullptr) entry.resource = make_unique<T>(asset, this->mediator);
T * concrete_resource = dynamic_cast<T *>(entry.resource.get());
if (concrete_resource == nullptr)
- throw runtime_error(format("ResourceManager: mismatch between requested type and "
- "actual type of resource ({})",
- asset.get_path()));
+ throw runtime_error(format(
+ "ResourceManager: mismatch between requested type and "
+ "actual type of resource ({})",
+ asset.get_path()
+ ));
return *concrete_resource;
}
diff --git a/src/crepe/manager/SceneManager.cpp b/src/crepe/manager/SceneManager.cpp
index d4ca90b..e6f92db 100644
--- a/src/crepe/manager/SceneManager.cpp
+++ b/src/crepe/manager/SceneManager.cpp
@@ -17,10 +17,12 @@ void SceneManager::load_next_scene() {
// next scene not set
if (this->next_scene.empty()) return;
- auto it = find_if(this->scenes.begin(), this->scenes.end(),
- [&next_scene = this->next_scene](unique_ptr<Scene> & scene) {
- return scene.get()->get_name() == next_scene;
- });
+ auto it = find_if(
+ this->scenes.begin(), this->scenes.end(),
+ [&next_scene = this->next_scene](unique_ptr<Scene> & scene) {
+ return scene.get()->get_name() == next_scene;
+ }
+ );
// next scene not found
if (it == this->scenes.end()) return;
diff --git a/src/crepe/manager/SystemManager.hpp b/src/crepe/manager/SystemManager.hpp
index 8d06eb1..addd274 100644
--- a/src/crepe/manager/SystemManager.hpp
+++ b/src/crepe/manager/SystemManager.hpp
@@ -11,8 +11,9 @@ namespace crepe {
template <class T>
T & SystemManager::get_system() {
using namespace std;
- static_assert(is_base_of<System, T>::value,
- "get_system must recieve a derivative class of System");
+ static_assert(
+ is_base_of<System, T>::value, "get_system must recieve a derivative class of System"
+ );
const type_info & type = typeid(T);
if (!this->systems.contains(type))
@@ -28,8 +29,9 @@ T & SystemManager::get_system() {
template <class T>
void SystemManager::load_system() {
using namespace std;
- static_assert(is_base_of<System, T>::value,
- "load_system must recieve a derivative class of System");
+ static_assert(
+ is_base_of<System, T>::value, "load_system must recieve a derivative class of System"
+ );
const type_info & type = typeid(T);
if (this->systems.contains(type))
diff --git a/src/crepe/system/AISystem.cpp b/src/crepe/system/AISystem.cpp
index 0f35010..94445c7 100644
--- a/src/crepe/system/AISystem.cpp
+++ b/src/crepe/system/AISystem.cpp
@@ -28,7 +28,8 @@ void AISystem::fixed_update() {
= mgr.get_components_by_id<Rigidbody>(ai.game_object_id);
if (rigidbodies.empty()) {
throw std::runtime_error(
- "AI component must be attached to a GameObject with a Rigidbody component");
+ "AI component must be attached to a GameObject with a Rigidbody component"
+ );
}
Rigidbody & rigidbody = rigidbodies.front().get();
if (!rigidbody.active) {
@@ -110,8 +111,8 @@ bool AISystem::accumulate_force(const AI & ai, vec2 & running_total, vec2 & forc
return true;
}
-vec2 AISystem::seek(const AI & ai, const Rigidbody & rigidbody,
- const Transform & transform) const {
+vec2 AISystem::seek(const AI & ai, const Rigidbody & rigidbody, const Transform & transform)
+ const {
// Calculate the desired velocity
vec2 desired_velocity = ai.seek_target - transform.position;
desired_velocity.normalize();
@@ -120,12 +121,12 @@ vec2 AISystem::seek(const AI & ai, const Rigidbody & rigidbody,
return desired_velocity - rigidbody.data.linear_velocity;
}
-vec2 AISystem::flee(const AI & ai, const Rigidbody & rigidbody,
- const Transform & transform) const {
+vec2 AISystem::flee(const AI & ai, const Rigidbody & rigidbody, const Transform & transform)
+ const {
// Calculate the desired velocity if the entity is within the panic distance
vec2 desired_velocity = transform.position - ai.flee_target;
if (desired_velocity.length_squared() > ai.square_flee_panic_distance) {
- return vec2{0, 0};
+ return vec2 {0, 0};
}
desired_velocity.normalize();
desired_velocity *= rigidbody.data.max_linear_velocity;
@@ -133,8 +134,8 @@ vec2 AISystem::flee(const AI & ai, const Rigidbody & rigidbody,
return desired_velocity - rigidbody.data.linear_velocity;
}
-vec2 AISystem::arrive(const AI & ai, const Rigidbody & rigidbody,
- const Transform & transform) const {
+vec2 AISystem::arrive(const AI & ai, const Rigidbody & rigidbody, const Transform & transform)
+ const {
// Calculate the desired velocity (taking into account the deceleration rate)
vec2 to_target = ai.arrive_target - transform.position;
float distance = to_target.length();
@@ -150,12 +151,12 @@ vec2 AISystem::arrive(const AI & ai, const Rigidbody & rigidbody,
return desired_velocity - rigidbody.data.linear_velocity;
}
- return vec2{0, 0};
+ return vec2 {0, 0};
}
vec2 AISystem::path_follow(AI & ai, const Rigidbody & rigidbody, const Transform & transform) {
if (ai.path.empty()) {
- return vec2{0, 0};
+ return vec2 {0, 0};
}
// Get the target node
diff --git a/src/crepe/system/CollisionSystem.cpp b/src/crepe/system/CollisionSystem.cpp
index 654d4c6..571ac70 100644
--- a/src/crepe/system/CollisionSystem.cpp
+++ b/src/crepe/system/CollisionSystem.cpp
@@ -50,9 +50,11 @@ void CollisionSystem::fixed_update() {
for (BoxCollider & boxcollider : boxcolliders) {
if (boxcollider.game_object_id != id) continue;
if (!boxcollider.active) continue;
- all_colliders.push_back({.id = id,
- .collider = collider_variant{boxcollider},
- .info = {transform, rigidbody, metadata}});
+ all_colliders.push_back(
+ {.id = id,
+ .collider = collider_variant {boxcollider},
+ .info = {transform, rigidbody, metadata}}
+ );
}
// Check if the circlecollider is active and has the same id as the rigidbody.
RefVector<CircleCollider> circlecolliders
@@ -60,9 +62,11 @@ void CollisionSystem::fixed_update() {
for (CircleCollider & circlecollider : circlecolliders) {
if (circlecollider.game_object_id != id) continue;
if (!circlecollider.active) continue;
- all_colliders.push_back({.id = id,
- .collider = collider_variant{circlecollider},
- .info = {transform, rigidbody, metadata}});
+ all_colliders.push_back(
+ {.id = id,
+ .collider = collider_variant {circlecollider},
+ .info = {transform, rigidbody, metadata}}
+ );
}
}
@@ -110,8 +114,9 @@ CollisionSystem::gather_collisions(std::vector<CollisionInternal> & colliders) {
return collisions_ret;
}
-bool CollisionSystem::should_collide(const CollisionInternal & self,
- const CollisionInternal & other) const {
+bool CollisionSystem::should_collide(
+ const CollisionInternal & self, const CollisionInternal & other
+) const {
const Rigidbody::Data & self_rigidbody = self.info.rigidbody.data;
const Rigidbody::Data & other_rigidbody = other.info.rigidbody.data;
@@ -133,9 +138,9 @@ bool CollisionSystem::should_collide(const CollisionInternal & self,
return false;
}
-CollisionSystem::CollisionInternalType
-CollisionSystem::get_collider_type(const collider_variant & collider1,
- const collider_variant & collider2) const {
+CollisionSystem::CollisionInternalType CollisionSystem::get_collider_type(
+ const collider_variant & collider1, const collider_variant & collider2
+) const {
if (std::holds_alternative<std::reference_wrapper<CircleCollider>>(collider1)) {
if (std::holds_alternative<std::reference_wrapper<CircleCollider>>(collider2)) {
return CollisionInternalType::CIRCLE_CIRCLE;
@@ -151,8 +156,9 @@ CollisionSystem::get_collider_type(const collider_variant & collider1,
}
}
-bool CollisionSystem::detect_collision(CollisionInternal & self, CollisionInternal & other,
- const CollisionInternalType & type) {
+bool CollisionSystem::detect_collision(
+ CollisionInternal & self, CollisionInternal & other, const CollisionInternalType & type
+) {
vec2 resolution;
switch (type) {
case CollisionInternalType::BOX_BOX: {
@@ -177,10 +183,11 @@ bool CollisionSystem::detect_collision(CollisionInternal & self, CollisionIntern
= {.collider = std::get<std::reference_wrapper<BoxCollider>>(self.collider),
.transform = self.info.transform,
.rigidbody = self.info.rigidbody};
- const CircleColliderInternal CIRCLE2 = {
- .collider = std::get<std::reference_wrapper<CircleCollider>>(other.collider),
- .transform = other.info.transform,
- .rigidbody = other.info.rigidbody};
+ const CircleColliderInternal CIRCLE2
+ = {.collider
+ = std::get<std::reference_wrapper<CircleCollider>>(other.collider),
+ .transform = other.info.transform,
+ .rigidbody = other.info.rigidbody};
// Get resolution vector from box-circle collision detection
resolution = this->get_box_circle_detection(BOX1, CIRCLE2);
// If no collision (NaN values), return false
@@ -195,10 +202,11 @@ bool CollisionSystem::detect_collision(CollisionInternal & self, CollisionIntern
= {.collider = std::get<std::reference_wrapper<CircleCollider>>(self.collider),
.transform = self.info.transform,
.rigidbody = self.info.rigidbody};
- const CircleColliderInternal CIRCLE2 = {
- .collider = std::get<std::reference_wrapper<CircleCollider>>(other.collider),
- .transform = other.info.transform,
- .rigidbody = other.info.rigidbody};
+ const CircleColliderInternal CIRCLE2
+ = {.collider
+ = std::get<std::reference_wrapper<CircleCollider>>(other.collider),
+ .transform = other.info.transform,
+ .rigidbody = other.info.rigidbody};
// Get resolution vector from circle-circle collision detection
resolution = this->get_circle_circle_detection(CIRCLE1, CIRCLE2);
// If no collision (NaN values), return false
@@ -239,9 +247,10 @@ bool CollisionSystem::detect_collision(CollisionInternal & self, CollisionIntern
return true;
}
-vec2 CollisionSystem::get_box_box_detection(const BoxColliderInternal & box1,
- const BoxColliderInternal & box2) const {
- vec2 resolution{NAN, NAN};
+vec2 CollisionSystem::get_box_box_detection(
+ const BoxColliderInternal & box1, const BoxColliderInternal & box2
+) const {
+ vec2 resolution {NAN, NAN};
// Get current positions of colliders
vec2 pos1 = AbsolutePosition::get_position(box1.transform, box1.collider.offset);
vec2 pos2 = AbsolutePosition::get_position(box2.transform, box2.collider.offset);
@@ -282,8 +291,9 @@ vec2 CollisionSystem::get_box_box_detection(const BoxColliderInternal & box1,
return resolution;
}
-vec2 CollisionSystem::get_box_circle_detection(const BoxColliderInternal & box,
- const CircleColliderInternal & circle) const {
+vec2 CollisionSystem::get_box_circle_detection(
+ const BoxColliderInternal & box, const CircleColliderInternal & circle
+) const {
/// Get current positions of colliders
vec2 box_pos = AbsolutePosition::get_position(box.transform, box.collider.offset);
vec2 circle_pos = AbsolutePosition::get_position(circle.transform, circle.collider.offset);
@@ -324,14 +334,15 @@ vec2 CollisionSystem::get_box_circle_detection(const BoxColliderInternal & box,
float penetration_depth = scaled_circle_radius - distance;
// Compute the resolution vector
- return vec2{collision_normal * penetration_depth};
+ return vec2 {collision_normal * penetration_depth};
}
// No collision
- return vec2{NAN, NAN};
+ return vec2 {NAN, NAN};
}
vec2 CollisionSystem::get_circle_circle_detection(
- const CircleColliderInternal & circle1, const CircleColliderInternal & circle2) const {
+ const CircleColliderInternal & circle1, const CircleColliderInternal & circle2
+) const {
// Get current positions of colliders
vec2 final_position1
= AbsolutePosition::get_position(circle1.transform, circle1.collider.offset);
@@ -371,7 +382,7 @@ vec2 CollisionSystem::get_circle_circle_detection(
return resolution;
}
// No collision
- return vec2{NAN, NAN};
+ return vec2 {NAN, NAN};
;
}
@@ -402,17 +413,17 @@ CollisionSystem::resolution_correction(vec2 & resolution, const Rigidbody::Data
return resolution_direction;
}
-CollisionSystem::CollisionInfo
-CollisionSystem::get_collision_info(const CollisionInternal & in_self,
- const CollisionInternal & in_other) const {
+CollisionSystem::CollisionInfo CollisionSystem::get_collision_info(
+ const CollisionInternal & in_self, const CollisionInternal & in_other
+) const {
- crepe::CollisionSystem::ColliderInfo self{
+ crepe::CollisionSystem::ColliderInfo self {
.transform = in_self.info.transform,
.rigidbody = in_self.info.rigidbody,
.metadata = in_self.info.metadata,
};
- crepe::CollisionSystem::ColliderInfo other{
+ crepe::CollisionSystem::ColliderInfo other {
.transform = in_other.info.transform,
.rigidbody = in_other.info.rigidbody,
.metadata = in_other.info.metadata,
diff --git a/src/crepe/system/CollisionSystem.h b/src/crepe/system/CollisionSystem.h
index 3fb9723..ff2d35f 100644
--- a/src/crepe/system/CollisionSystem.h
+++ b/src/crepe/system/CollisionSystem.h
@@ -60,8 +60,8 @@ public:
private:
//! A variant type that can hold either a BoxCollider or a CircleCollider.
- using collider_variant = std::variant<std::reference_wrapper<BoxCollider>,
- std::reference_wrapper<CircleCollider>>;
+ using collider_variant = std::variant<
+ std::reference_wrapper<BoxCollider>, std::reference_wrapper<CircleCollider>>;
//! Enum representing the types of collider pairs for collision detection.
enum class CollisionInternalType {
@@ -114,8 +114,9 @@ private:
* \param collider2 Second collider variant (BoxCollider or CircleCollider).
* \return The combined type of the two colliders.
*/
- CollisionInternalType get_collider_type(const collider_variant & collider1,
- const collider_variant & collider2) const;
+ CollisionInternalType get_collider_type(
+ const collider_variant & collider1, const collider_variant & collider2
+ ) const;
private:
/**
@@ -128,8 +129,8 @@ private:
* \param data1 Collision data for the first collider.
* \param data2 Collision data for the second collider.
*/
- CollisionInfo get_collision_info(const CollisionInternal & data1,
- const CollisionInternal & data2) const;
+ CollisionInfo
+ get_collision_info(const CollisionInternal & data1, const CollisionInternal & data2) const;
/**
* \brief Corrects the collision resolution vector and determines its direction.
@@ -221,8 +222,10 @@ private:
* \param other_metadata Rigidbody of second object
* \return Returns true if there is at least one comparison found.
*/
- bool should_collide(const CollisionInternal & self,
- const CollisionInternal & other) const; //done
+ bool should_collide(
+ const CollisionInternal & self,
+ const CollisionInternal & other
+ ) const; //done
/**
* \brief Checks for collision between two colliders.
@@ -236,8 +239,10 @@ private:
* \param type The type of collider pair.
* \return True if a collision is detected, otherwise false.
*/
- bool detect_collision(CollisionInternal & first_info, CollisionInternal & second_info,
- const CollisionInternalType & type);
+ bool detect_collision(
+ CollisionInternal & first_info, CollisionInternal & second_info,
+ const CollisionInternalType & type
+ );
/**
* \brief Detects collisions between two BoxColliders.
@@ -250,8 +255,9 @@ private:
* \param box2 Information about the second BoxCollider.
* \return If colliding, returns the resolution vector; otherwise, returns {NaN, NaN}.
*/
- vec2 get_box_box_detection(const BoxColliderInternal & box1,
- const BoxColliderInternal & box2) const;
+ vec2 get_box_box_detection(
+ const BoxColliderInternal & box1, const BoxColliderInternal & box2
+ ) const;
/**
* \brief Check collision for box on circle collider
@@ -264,8 +270,9 @@ private:
* \param circle2 Information about the circleCollider.
* \return If colliding, returns the resolution vector; otherwise, returns {NaN, NaN}.
*/
- vec2 get_box_circle_detection(const BoxColliderInternal & box1,
- const CircleColliderInternal & circle2) const;
+ vec2 get_box_circle_detection(
+ const BoxColliderInternal & box1, const CircleColliderInternal & circle2
+ ) const;
/**
* \brief Check collision for circle on circle collider
@@ -278,8 +285,9 @@ private:
* \param circle2 Information about the second circleCollider.
* \return If colliding, returns the resolution vector; otherwise, returns {NaN, NaN}.
*/
- vec2 get_circle_circle_detection(const CircleColliderInternal & circle1,
- const CircleColliderInternal & circle2) const;
+ vec2 get_circle_circle_detection(
+ const CircleColliderInternal & circle1, const CircleColliderInternal & circle2
+ ) const;
};
/**
diff --git a/src/crepe/system/InputSystem.cpp b/src/crepe/system/InputSystem.cpp
index 8e9f763..b4a0633 100644
--- a/src/crepe/system/InputSystem.cpp
+++ b/src/crepe/system/InputSystem.cpp
@@ -44,8 +44,9 @@ void InputSystem::fixed_update() {
}
}
-void InputSystem::handle_mouse_event(const EventData & event, const vec2 & camera_origin,
- const Camera & current_cam) {
+void InputSystem::handle_mouse_event(
+ const EventData & event, const vec2 & camera_origin, const Camera & current_cam
+) {
EventManager & event_mgr = this->mediator.event_manager;
vec2 adjusted_mouse;
adjusted_mouse.x = event.data.mouse_data.mouse_position.x + camera_origin.x;
@@ -82,8 +83,9 @@ void InputSystem::handle_mouse_event(const EventData & event, const vec2 & camer
.mouse_pos = adjusted_mouse,
.button = event.data.mouse_data.mouse_button,
});
- this->handle_click(event.data.mouse_data.mouse_button, adjusted_mouse,
- current_cam);
+ this->handle_click(
+ event.data.mouse_data.mouse_button, adjusted_mouse, current_cam
+ );
}
break;
}
@@ -115,7 +117,8 @@ void InputSystem::handle_non_mouse_event(const EventData & event) {
case EventType::KEY_DOWN:
event_mgr.queue_event<KeyPressEvent>(
- {.repeat = event.data.key_data.key_repeat, .key = event.data.key_data.key});
+ {.repeat = event.data.key_data.key_repeat, .key = event.data.key_data.key}
+ );
break;
case EventType::KEY_UP:
event_mgr.queue_event<KeyReleaseEvent>({.key = event.data.key_data.key});
@@ -128,11 +131,13 @@ void InputSystem::handle_non_mouse_event(const EventData & event) {
break;
case EventType::WINDOW_RESIZE:
event_mgr.queue_event<WindowResizeEvent>(
- WindowResizeEvent{.dimensions = event.data.window_data.resize_dimension});
+ WindowResizeEvent {.dimensions = event.data.window_data.resize_dimension}
+ );
break;
case EventType::WINDOW_MOVE:
event_mgr.queue_event<WindowMoveEvent>(
- {.delta_move = event.data.window_data.move_delta});
+ {.delta_move = event.data.window_data.move_delta}
+ );
break;
case EventType::WINDOW_MINIMIZE:
event_mgr.queue_event<WindowMinimizeEvent>({});
@@ -151,8 +156,9 @@ void InputSystem::handle_non_mouse_event(const EventData & event) {
}
}
-void InputSystem::handle_move(const EventData & event_data, const vec2 & mouse_pos,
- const Camera & current_cam) {
+void InputSystem::handle_move(
+ const EventData & event_data, const vec2 & mouse_pos, const Camera & current_cam
+) {
ComponentManager & mgr = this->mediator.component_manager;
EventManager & event_mgr = this->mediator.event_manager;
const RefVector<Button> buttons = mgr.get_components_by_type<Button>();
@@ -182,8 +188,9 @@ void InputSystem::handle_move(const EventData & event_data, const vec2 & mouse_p
}
}
-void InputSystem::handle_click(const MouseButton & mouse_button, const vec2 & mouse_pos,
- const Camera & current_cam) {
+void InputSystem::handle_click(
+ const MouseButton & mouse_button, const vec2 & mouse_pos, const Camera & current_cam
+) {
ComponentManager & mgr = this->mediator.component_manager;
EventManager & event_mgr = this->mediator.event_manager;
const RefVector<Button> buttons = mgr.get_components_by_type<Button>();
@@ -201,9 +208,10 @@ void InputSystem::handle_click(const MouseButton & mouse_button, const vec2 & mo
}
}
-bool InputSystem::is_mouse_inside_button(const vec2 & mouse_pos, const Button & button,
- const Transform & transform,
- const Transform & cam_transform) {
+bool InputSystem::is_mouse_inside_button(
+ const vec2 & mouse_pos, const Button & button, const Transform & transform,
+ const Transform & cam_transform
+) {
vec2 actual_pos = transform.position + button.offset;
if (!button.world_space) {
actual_pos += cam_transform.position;
diff --git a/src/crepe/system/InputSystem.h b/src/crepe/system/InputSystem.h
index 45b238b..37311cc 100644
--- a/src/crepe/system/InputSystem.h
+++ b/src/crepe/system/InputSystem.h
@@ -79,8 +79,9 @@ private:
* This method processes mouse events, adjusts the mouse position to world coordinates,
* and triggers the appropriate mouse-specific event handling logic.
*/
- void handle_mouse_event(const EventData & event, const vec2 & camera_origin,
- const Camera & current_cam);
+ void handle_mouse_event(
+ const EventData & event, const vec2 & camera_origin, const Camera & current_cam
+ );
/**
* \brief Handles non-mouse-related events.
* \param event The event data for the non-mouse event.
@@ -98,8 +99,9 @@ private:
*
* This method processes the mouse click event and triggers the corresponding button action.
*/
- void handle_click(const MouseButton & mouse_button, const vec2 & mouse_pos,
- const Camera & current_cam);
+ void handle_click(
+ const MouseButton & mouse_button, const vec2 & mouse_pos, const Camera & current_cam
+ );
/**
* \brief Handles the mouse movement event.
@@ -110,8 +112,9 @@ private:
*
* This method processes the mouse movement event and updates the button hover state.
*/
- void handle_move(const EventData & event_data, const vec2 & mouse_pos,
- const Camera & current_cam);
+ void handle_move(
+ const EventData & event_data, const vec2 & mouse_pos, const Camera & current_cam
+ );
/**
* \brief Checks if the mouse position is inside the bounds of the button.
@@ -122,8 +125,10 @@ private:
* \param cam_transform the transform of the current active camera
* \return True if the mouse is inside the button, false otherwise.
*/
- bool is_mouse_inside_button(const vec2 & mouse_pos, const Button & button,
- const Transform & transform, const Transform & cam_transform);
+ bool is_mouse_inside_button(
+ const vec2 & mouse_pos, const Button & button, const Transform & transform,
+ const Transform & cam_transform
+ );
/**
* \brief Handles the button press event, calling the on_click callback if necessary.
diff --git a/src/crepe/system/ParticleSystem.cpp b/src/crepe/system/ParticleSystem.cpp
index 5e575e4..f026390 100644
--- a/src/crepe/system/ParticleSystem.cpp
+++ b/src/crepe/system/ParticleSystem.cpp
@@ -50,9 +50,10 @@ void ParticleSystem::emit_particle(ParticleEmitter & emitter, const Transform &
constexpr float DEG_TO_RAD = M_PI / 180.0;
vec2 initial_position = AbsolutePosition::get_position(transform, emitter.data.offset);
- float random_angle
- = this->generate_random_angle(emitter.data.min_angle + transform.rotation,
- emitter.data.max_angle + transform.rotation);
+ float random_angle = this->generate_random_angle(
+ emitter.data.min_angle + transform.rotation,
+ emitter.data.max_angle + transform.rotation
+ );
float random_speed
= this->generate_random_speed(emitter.data.min_speed, emitter.data.max_speed);
@@ -63,8 +64,9 @@ void ParticleSystem::emit_particle(ParticleEmitter & emitter, const Transform &
for (Particle & particle : emitter.particles) {
if (!particle.active) {
- particle.reset(emitter.data.end_lifespan, initial_position, velocity,
- random_angle);
+ particle.reset(
+ emitter.data.end_lifespan, initial_position, velocity, random_angle
+ );
break;
}
}
@@ -82,8 +84,9 @@ void ParticleSystem::check_bounds(ParticleEmitter & emitter, const Transform & t
for (Particle & particle : emitter.particles) {
const vec2 & position = particle.position;
- bool within_bounds = (position.x >= left && position.x <= right && position.y >= top
- && position.y <= bottom);
+ bool within_bounds
+ = (position.x >= left && position.x <= right && position.y >= top
+ && position.y <= bottom);
//if not within bounds do a reset or stop velocity
if (!within_bounds) {
if (emitter.data.boundary.reset_on_exit) {
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp
index 698301e..30bb422 100644
--- a/src/crepe/system/RenderSystem.cpp
+++ b/src/crepe/system/RenderSystem.cpp
@@ -92,7 +92,7 @@ void RenderSystem::render_text() {
const Font & font = resource_manager.get<Font>(text.font.value());
const auto & transform
= mgr.get_components_by_id<Transform>(text.game_object_id).front().get();
- ctx.draw_text(SDLContext::RenderText{
+ ctx.draw_text(SDLContext::RenderText {
.text = text,
.font = font,
.transform = transform,
@@ -120,7 +120,7 @@ bool RenderSystem::render_particle(const Sprite & sprite, const Transform & tran
if (!p.active) continue;
if (p.time_in_life < em.data.begin_lifespan) continue;
- ctx.draw(SDLContext::RenderContext{
+ ctx.draw(SDLContext::RenderContext {
.sprite = sprite,
.texture = res,
.pos = p.position,
@@ -136,7 +136,7 @@ void RenderSystem::render_normal(const Sprite & sprite, const Transform & transf
ResourceManager & resource_manager = this->mediator.resource_manager;
const Texture & res = resource_manager.get<Texture>(sprite.source);
vec2 pos = AbsolutePosition::get_position(transform, sprite.data.position_offset);
- ctx.draw(SDLContext::RenderContext{
+ ctx.draw(SDLContext::RenderContext {
.sprite = sprite,
.texture = res,
.pos = pos,
diff --git a/src/crepe/system/ScriptSystem.cpp b/src/crepe/system/ScriptSystem.cpp
index 93b4853..ed0c7cc 100644
--- a/src/crepe/system/ScriptSystem.cpp
+++ b/src/crepe/system/ScriptSystem.cpp
@@ -19,8 +19,9 @@ void ScriptSystem::frame_update() {
this->update(&Script::frame_update, delta_time);
}
-void ScriptSystem::update(void (Script::*update_function)(duration_t),
- const duration_t & delta_time) {
+void ScriptSystem::update(
+ void (Script::*update_function)(duration_t), const duration_t & delta_time
+) {
ComponentManager & mgr = this->mediator.component_manager;
RefVector<BehaviorScript> behavior_scripts = mgr.get_components_by_type<BehaviorScript>();
diff --git a/src/crepe/util/dbg.h b/src/crepe/util/dbg.h
index c7283ee..e448070 100644
--- a/src/crepe/util/dbg.h
+++ b/src/crepe/util/dbg.h
@@ -5,10 +5,13 @@
// utility macros
#define _crepe_logf_here(level, fmt, ...) \
- crepe::Log::logf(level, "{}" fmt, \
- crepe::LogColor().fg_white(false).str(std::format( \
- "{} ({}:{})", __PRETTY_FUNCTION__, __FILE_NAME__, __LINE__)), \
- __VA_ARGS__)
+ crepe::Log::logf( \
+ level, "{}" fmt, \
+ crepe::LogColor().fg_white(false).str( \
+ std::format("{} ({}:{})", __PRETTY_FUNCTION__, __FILE_NAME__, __LINE__) \
+ ), \
+ __VA_ARGS__ \
+ )
// very illegal global function-style macros
// NOLINTBEGIN