From 1df510f4a2dbe0fcb8c9f8a34695abf8d33f9ddc Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 13 Nov 2024 14:35:27 +0100 Subject: update logging to use C++20 format and classes --- src/crepe/util/Log.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/crepe/util/Log.hpp (limited to 'src/crepe/util/Log.hpp') diff --git a/src/crepe/util/Log.hpp b/src/crepe/util/Log.hpp new file mode 100644 index 0000000..58ba475 --- /dev/null +++ b/src/crepe/util/Log.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "Log.h" + +namespace crepe { + +template +void Log::logf(std::format_string fmt, Args&&... args) { + Log::logf(Level::INFO, fmt, std::forward(args)...); +} + +template +void Log::logf(const Level & level, std::format_string fmt, Args&&... args) { + Log::log(level, std::format(fmt, std::forward(args)...)); +} + +} + -- cgit v1.2.3 From 5e59c22f77073fdf49bf98697da6a68819eb5776 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 13 Nov 2024 15:50:13 +0100 Subject: `make format` --- src/crepe/Asset.cpp | 1 - src/crepe/Exception.cpp | 5 +---- src/crepe/Exception.h | 7 +++---- src/crepe/Exception.hpp | 7 +++---- src/crepe/api/Config.h | 1 + src/crepe/api/Script.hpp | 3 ++- src/crepe/util/Log.cpp | 1 - src/crepe/util/Log.h | 17 +++++++++++------ src/crepe/util/Log.hpp | 12 ++++++------ src/example/log.cpp | 1 - src/example/proxy.cpp | 2 +- src/example/savemgr.cpp | 2 +- 12 files changed, 29 insertions(+), 30 deletions(-) (limited to 'src/crepe/util/Log.hpp') diff --git a/src/crepe/Asset.cpp b/src/crepe/Asset.cpp index 4affd58..9c41ecb 100644 --- a/src/crepe/Asset.cpp +++ b/src/crepe/Asset.cpp @@ -14,4 +14,3 @@ Asset::Asset(const std::string & src) : src(src) { istream & Asset::get_stream() { return this->file; } const string & Asset::get_canonical() const { return this->src; } - diff --git a/src/crepe/Exception.cpp b/src/crepe/Exception.cpp index 3217169..5a24e7e 100644 --- a/src/crepe/Exception.cpp +++ b/src/crepe/Exception.cpp @@ -5,7 +5,4 @@ using namespace std; const char * Exception::what() const noexcept { return error.c_str(); } -Exception::Exception(const string & msg) { - this->error = msg; -} - +Exception::Exception(const string & msg) { this->error = msg; } diff --git a/src/crepe/Exception.h b/src/crepe/Exception.h index ed3ab15..580fc16 100644 --- a/src/crepe/Exception.h +++ b/src/crepe/Exception.h @@ -1,8 +1,8 @@ #pragma once #include -#include #include +#include namespace crepe { @@ -13,8 +13,8 @@ public: Exception(const std::string & msg); //! Exception with \c std::format message - template - Exception(std::format_string fmt, Args&&... args); + template + Exception(std::format_string fmt, Args &&... args); //! Get formatted error message const char * what() const noexcept; @@ -29,4 +29,3 @@ protected: } // namespace crepe #include "Exception.hpp" - diff --git a/src/crepe/Exception.hpp b/src/crepe/Exception.hpp index d813879..7c462a3 100644 --- a/src/crepe/Exception.hpp +++ b/src/crepe/Exception.hpp @@ -4,10 +4,9 @@ namespace crepe { -template -Exception::Exception(std::format_string fmt, Args&&... args) { +template +Exception::Exception(std::format_string fmt, Args &&... args) { this->error = std::format(fmt, std::forward(args)...); } -} - +} // namespace crepe diff --git a/src/crepe/api/Config.h b/src/crepe/api/Config.h index dad7e08..e3f86bf 100644 --- a/src/crepe/api/Config.h +++ b/src/crepe/api/Config.h @@ -7,6 +7,7 @@ namespace crepe { class Config { private: Config() = default; + public: ~Config() = default; diff --git a/src/crepe/api/Script.hpp b/src/crepe/api/Script.hpp index afe653f..d755fda 100644 --- a/src/crepe/api/Script.hpp +++ b/src/crepe/api/Script.hpp @@ -13,7 +13,8 @@ T & Script::get_component() const { std::vector> all_components = this->get_components(); if (all_components.size() < 1) - throw Exception("Script: no component found with type = %s", typeid(T).name()); + throw Exception("Script: no component found with type = %s", + typeid(T).name()); return all_components.back().get(); } diff --git a/src/crepe/util/Log.cpp b/src/crepe/util/Log.cpp index 346e08e..e583734 100644 --- a/src/crepe/util/Log.cpp +++ b/src/crepe/util/Log.cpp @@ -36,4 +36,3 @@ void Log::log(const Level & level, const string & msg) { fwrite(out.c_str(), 1, out.size(), stdout); fflush(stdout); } - diff --git a/src/crepe/util/Log.h b/src/crepe/util/Log.h index 4e32e9d..01452b2 100644 --- a/src/crepe/util/Log.h +++ b/src/crepe/util/Log.h @@ -8,7 +8,12 @@ #include "LogColor.h" // 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__) +#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__) // very illegal global function-style macros // NOLINTBEGIN @@ -53,8 +58,9 @@ public: * \param fmt Message format * \param args Format arguments */ - template - static void logf(const Level & level, std::format_string fmt, Args&&... args); + template + static void logf(const Level & level, std::format_string fmt, + Args &&... args); /** * \brief Format a message and log it (with default severity \c INFO) @@ -62,8 +68,8 @@ public: * \param fmt Message format * \param args Format arguments */ - template - static void logf(std::format_string fmt, Args&&... args); + template + static void logf(std::format_string fmt, Args &&... args); private: /** @@ -77,4 +83,3 @@ private: } // namespace crepe #include "Log.hpp" - diff --git a/src/crepe/util/Log.hpp b/src/crepe/util/Log.hpp index 58ba475..651f076 100644 --- a/src/crepe/util/Log.hpp +++ b/src/crepe/util/Log.hpp @@ -4,15 +4,15 @@ namespace crepe { -template -void Log::logf(std::format_string fmt, Args&&... args) { +template +void Log::logf(std::format_string fmt, Args &&... args) { Log::logf(Level::INFO, fmt, std::forward(args)...); } -template -void Log::logf(const Level & level, std::format_string fmt, Args&&... args) { +template +void Log::logf(const Level & level, std::format_string fmt, + Args &&... args) { Log::log(level, std::format(fmt, std::forward(args)...)); } -} - +} // namespace crepe diff --git a/src/example/log.cpp b/src/example/log.cpp index 13d592b..5baa021 100644 --- a/src/example/log.cpp +++ b/src/example/log.cpp @@ -23,7 +23,6 @@ int main() { Log::logf("info message with variable: {}", 3); Log::logf(Log::Level::WARNING, "warning"); Log::logf(Log::Level::ERROR, "error"); - return 0; } diff --git a/src/example/proxy.cpp b/src/example/proxy.cpp index ca68d9a..69451f8 100644 --- a/src/example/proxy.cpp +++ b/src/example/proxy.cpp @@ -5,8 +5,8 @@ #include #include -#include #include +#include using namespace std; using namespace crepe; diff --git a/src/example/savemgr.cpp b/src/example/savemgr.cpp index 5a415b7..65c4a34 100644 --- a/src/example/savemgr.cpp +++ b/src/example/savemgr.cpp @@ -6,8 +6,8 @@ #include #include #include -#include #include +#include using namespace crepe; -- cgit v1.2.3 From fdd5c471dffd4a204a91e8d1d70567fa56ea29a5 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 15 Nov 2024 20:49:37 +0100 Subject: `make format` --- src/crepe/Component.h | 1 + src/crepe/ComponentManager.cpp | 4 ++-- src/crepe/ComponentManager.h | 7 +++---- src/crepe/api/Animator.cpp | 3 +-- src/crepe/api/Camera.cpp | 4 +++- src/crepe/api/GameObject.cpp | 12 +++++++++--- src/crepe/api/GameObject.h | 4 +++- src/crepe/api/LoopManager.cpp | 4 +--- src/crepe/api/LoopManager.hpp | 2 +- src/crepe/api/Script.hpp | 3 ++- src/crepe/api/Vector2.cpp | 20 +++++--------------- src/crepe/facade/DB.cpp | 15 ++++++--------- src/crepe/facade/Sound.cpp | 4 +--- src/crepe/system/RenderSystem.cpp | 4 +--- src/crepe/util/Log.h | 15 ++++++--------- src/crepe/util/Log.hpp | 3 +-- src/example/ecs.cpp | 12 ++++-------- src/example/scene_manager.cpp | 21 +++++++-------------- src/test/PhysicsTest.cpp | 12 ++++-------- 19 files changed, 61 insertions(+), 89 deletions(-) (limited to 'src/crepe/util/Log.hpp') diff --git a/src/crepe/Component.h b/src/crepe/Component.h index 68b28ef..5279fb3 100644 --- a/src/crepe/Component.h +++ b/src/crepe/Component.h @@ -26,6 +26,7 @@ protected: Component(game_object_id_t id); //! Only the ComponentManager can create components friend class ComponentManager; + public: virtual ~Component() = default; diff --git a/src/crepe/ComponentManager.cpp b/src/crepe/ComponentManager.cpp index 67c6fc7..e310577 100644 --- a/src/crepe/ComponentManager.cpp +++ b/src/crepe/ComponentManager.cpp @@ -26,8 +26,8 @@ void ComponentManager::delete_all_components() { } GameObject ComponentManager::new_object(const string & name, const string & tag, - const Vector2 & position, - double rotation, double scale) { + const Vector2 & position, double rotation, + double scale) { GameObject object{*this, this->next_id, name, tag, position, rotation, scale}; this->next_id++; return object; diff --git a/src/crepe/ComponentManager.h b/src/crepe/ComponentManager.h index a14cb46..99d45d9 100644 --- a/src/crepe/ComponentManager.h +++ b/src/crepe/ComponentManager.h @@ -100,10 +100,9 @@ public: std::vector> get_components_by_type() const; // TODO: doxygen - GameObject new_object(const std::string & name, - const std::string & tag = "", - const Vector2 & position = {0, 0}, - double rotation = 0, double scale = 0); + GameObject new_object(const std::string & name, const std::string & tag = "", + const Vector2 & position = {0, 0}, double rotation = 0, + double scale = 0); private: /** diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp index cccbc67..464b0fd 100644 --- a/src/crepe/api/Animator.cpp +++ b/src/crepe/api/Animator.cpp @@ -7,8 +7,7 @@ using namespace crepe; -Animator::Animator(game_object_id_t id, Sprite & ss, int row, int col, - int col_animator) +Animator::Animator(game_object_id_t id, Sprite & ss, int row, int col, int col_animator) : Component(id), spritesheet(ss), row(row), diff --git a/src/crepe/api/Camera.cpp b/src/crepe/api/Camera.cpp index eb99f7f..5835bdd 100644 --- a/src/crepe/api/Camera.cpp +++ b/src/crepe/api/Camera.cpp @@ -6,7 +6,9 @@ using namespace crepe; -Camera::Camera(game_object_id_t id, const Color & bg_color) : Component(id), bg_color(bg_color) { +Camera::Camera(game_object_id_t id, const Color & bg_color) + : Component(id), + bg_color(bg_color) { dbg_trace(); } diff --git a/src/crepe/api/GameObject.cpp b/src/crepe/api/GameObject.cpp index 2b836e1..287e81d 100644 --- a/src/crepe/api/GameObject.cpp +++ b/src/crepe/api/GameObject.cpp @@ -7,7 +7,11 @@ using namespace crepe; using namespace std; -GameObject::GameObject(ComponentManager & component_manager, game_object_id_t id, const std::string & name, const std::string & tag, const Vector2 & position, double rotation, double scale) : id(id), component_manager(component_manager) { +GameObject::GameObject(ComponentManager & component_manager, game_object_id_t id, + const std::string & name, const std::string & tag, + const Vector2 & position, double rotation, double scale) + : id(id), + component_manager(component_manager) { // Add Transform and Metadata components ComponentManager & mgr = this->component_manager; @@ -19,10 +23,12 @@ void GameObject::set_parent(const GameObject & parent) { ComponentManager & mgr = this->component_manager; // Set parent on own Metadata component - vector> this_metadata = mgr.get_components_by_id(this->id); + vector> this_metadata + = mgr.get_components_by_id(this->id); this_metadata.at(0).get().parent = parent.id; // Add own id to children list of parent's Metadata component - vector> parent_metadata = mgr.get_components_by_id(parent.id); + vector> parent_metadata + = mgr.get_components_by_id(parent.id); parent_metadata.at(0).get().children.push_back(this->id); } diff --git a/src/crepe/api/GameObject.h b/src/crepe/api/GameObject.h index cf6765a..34ef8bb 100644 --- a/src/crepe/api/GameObject.h +++ b/src/crepe/api/GameObject.h @@ -29,7 +29,9 @@ private: * \param rotation The rotation of the GameObject * \param scale The scale of the GameObject */ - GameObject(ComponentManager & component_manager, game_object_id_t id, const std::string & name, const std::string & tag, const Vector2 & position, double rotation, double scale); + GameObject(ComponentManager & component_manager, game_object_id_t id, + const std::string & name, const std::string & tag, const Vector2 & position, + double rotation, double scale); //! ComponentManager instances GameObject friend class ComponentManager; diff --git a/src/crepe/api/LoopManager.cpp b/src/crepe/api/LoopManager.cpp index f0788ab..6303e2b 100644 --- a/src/crepe/api/LoopManager.cpp +++ b/src/crepe/api/LoopManager.cpp @@ -22,9 +22,7 @@ LoopManager::LoopManager() { this->load_system(); } -ComponentManager & LoopManager::get_component_manager() { - return this->component_manager; -} +ComponentManager & LoopManager::get_component_manager() { return this->component_manager; } void LoopManager::process_input() { SDLContext::get_instance().handle_events(this->game_running); diff --git a/src/crepe/api/LoopManager.hpp b/src/crepe/api/LoopManager.hpp index 85a329b..0b14fdb 100644 --- a/src/crepe/api/LoopManager.hpp +++ b/src/crepe/api/LoopManager.hpp @@ -1,8 +1,8 @@ #pragma once #include -#include #include +#include #include "../system/System.h" diff --git a/src/crepe/api/Script.hpp b/src/crepe/api/Script.hpp index 13b8077..c4e07e8 100644 --- a/src/crepe/api/Script.hpp +++ b/src/crepe/api/Script.hpp @@ -12,7 +12,8 @@ T & Script::get_component() const { using namespace std; vector> all_components = this->get_components(); if (all_components.size() < 1) - throw runtime_error(format("Script: no component found with type = {}", typeid(T).name())); + throw runtime_error( + format("Script: no component found with type = {}", typeid(T).name())); return all_components.back().get(); } diff --git a/src/crepe/api/Vector2.cpp b/src/crepe/api/Vector2.cpp index 97b74ac..30b968e 100644 --- a/src/crepe/api/Vector2.cpp +++ b/src/crepe/api/Vector2.cpp @@ -2,17 +2,11 @@ using namespace crepe; -Vector2 Vector2::operator-(const Vector2 & other) const { - return {x - other.x, y - other.y}; -} +Vector2 Vector2::operator-(const Vector2 & other) const { return {x - other.x, y - other.y}; } -Vector2 Vector2::operator+(const Vector2 & other) const { - return {x + other.x, y + other.y}; -} +Vector2 Vector2::operator+(const Vector2 & other) const { return {x + other.x, y + other.y}; } -Vector2 Vector2::operator*(double scalar) const { - return {x * scalar, y * scalar}; -} +Vector2 Vector2::operator*(double scalar) const { return {x * scalar, y * scalar}; } Vector2 & Vector2::operator*=(const Vector2 & other) { x *= other.x; @@ -34,10 +28,6 @@ Vector2 & Vector2::operator+=(double other) { Vector2 Vector2::operator-() const { return {-x, -y}; } -bool Vector2::operator==(const Vector2 & other) const { - return x == other.x && y == other.y; -} +bool Vector2::operator==(const Vector2 & other) const { return x == other.x && y == other.y; } -bool Vector2::operator!=(const Vector2 & other) const { - return !(*this == other); -} +bool Vector2::operator!=(const Vector2 & other) const { return !(*this == other); } diff --git a/src/crepe/facade/DB.cpp b/src/crepe/facade/DB.cpp index 00acf04..d5d19dc 100644 --- a/src/crepe/facade/DB.cpp +++ b/src/crepe/facade/DB.cpp @@ -18,7 +18,8 @@ DB::DB(const string & path) { this->db = {db, [](libdb::DB * db) { db->close(db, 0); }}; // load or create database file - ret = this->db->open(this->db.get(), NULL, path.c_str(), NULL, libdb::DB_BTREE, DB_CREATE, 0); + ret = this->db->open(this->db.get(), NULL, path.c_str(), NULL, libdb::DB_BTREE, DB_CREATE, + 0); if (ret != 0) throw runtime_error(format("db->open: {}", libdb::db_strerror(ret))); // create cursor @@ -42,22 +43,18 @@ string DB::get(const string & key) { memset(&db_val, 0, sizeof(libdb::DBT)); int ret = this->cursor->get(this->cursor.get(), &db_key, &db_val, DB_FIRST); - if (ret == 0) - return {static_cast(db_val.data), db_val.size}; + if (ret == 0) return {static_cast(db_val.data), db_val.size}; string err = format("cursor->get: {}", libdb::db_strerror(ret)); - if (ret == DB_NOTFOUND) - throw out_of_range(err); - else - throw runtime_error(err); + if (ret == DB_NOTFOUND) throw out_of_range(err); + else throw runtime_error(err); } void DB::set(const string & key, const string & value) { libdb::DBT db_key = this->to_thing(key); libdb::DBT db_val = this->to_thing(value); int ret = this->db->put(this->db.get(), NULL, &db_key, &db_val, 0); - if (ret != 0) - throw runtime_error(format("cursor->get: {}", libdb::db_strerror(ret))); + if (ret != 0) throw runtime_error(format("cursor->get: {}", libdb::db_strerror(ret))); } bool DB::has(const std::string & key) { diff --git a/src/crepe/facade/Sound.cpp b/src/crepe/facade/Sound.cpp index a65b052..7aa89a9 100644 --- a/src/crepe/facade/Sound.cpp +++ b/src/crepe/facade/Sound.cpp @@ -16,9 +16,7 @@ Sound::Sound(const char * src) { this->load(make_unique(src)); } -void Sound::load(unique_ptr res) { - this->sample.load(res->get_canonical().c_str()); -} +void Sound::load(unique_ptr res) { this->sample.load(res->get_canonical().c_str()); } void Sound::play() { SoundContext & ctx = SoundContext::get_instance(); diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp index 19493f7..fa3d0de 100644 --- a/src/crepe/system/RenderSystem.cpp +++ b/src/crepe/system/RenderSystem.cpp @@ -11,9 +11,7 @@ using namespace crepe; -void RenderSystem::clear_screen() const { - SDLContext::get_instance().clear_screen(); -} +void RenderSystem::clear_screen() const { SDLContext::get_instance().clear_screen(); } void RenderSystem::present_screen() const { SDLContext::get_instance().present_screen(); } void RenderSystem::update_camera() { diff --git a/src/crepe/util/Log.h b/src/crepe/util/Log.h index e0844ca..d55b11e 100644 --- a/src/crepe/util/Log.h +++ b/src/crepe/util/Log.h @@ -9,16 +9,14 @@ // 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 -#define dbg_logf(fmt, ...) \ - _crepe_logf_here(crepe::Log::Level::DEBUG, ": " fmt, __VA_ARGS__) +#define dbg_logf(fmt, ...) _crepe_logf_here(crepe::Log::Level::DEBUG, ": " fmt, __VA_ARGS__) #define dbg_log(str) _crepe_logf_here(crepe::Log::Level::DEBUG, ": {}", str) #define dbg_trace() _crepe_logf_here(crepe::Log::Level::TRACE, "", "") // NOLINTEND @@ -59,8 +57,7 @@ public: * \param args Format arguments */ template - static void logf(const Level & level, std::format_string fmt, - Args &&... args); + static void logf(const Level & level, std::format_string fmt, Args &&... args); /** * \brief Format a message and log it (with default severity \c INFO) diff --git a/src/crepe/util/Log.hpp b/src/crepe/util/Log.hpp index 651f076..c2156cd 100644 --- a/src/crepe/util/Log.hpp +++ b/src/crepe/util/Log.hpp @@ -10,8 +10,7 @@ void Log::logf(std::format_string fmt, Args &&... args) { } template -void Log::logf(const Level & level, std::format_string fmt, - Args &&... args) { +void Log::logf(const Level & level, std::format_string fmt, Args &&... args) { Log::log(level, std::format(fmt, std::forward(args)...)); } diff --git a/src/example/ecs.cpp b/src/example/ecs.cpp index 711bde6..d5ba51b 100644 --- a/src/example/ecs.cpp +++ b/src/example/ecs.cpp @@ -14,14 +14,10 @@ int main() { // Create a few GameObjects try { GameObject body = mgr.new_object("body", "person", Vector2{0, 0}, 0, 1); - GameObject right_leg - = mgr.new_object("rightLeg", "person", Vector2{1, 1}, 0, 1); - GameObject left_leg - = mgr.new_object("leftLeg", "person", Vector2{1, 1}, 0, 1); - GameObject right_foot - = mgr.new_object("rightFoot", "person", Vector2{2, 2}, 0, 1); - GameObject left_foot - = mgr.new_object("leftFoot", "person", Vector2{2, 2}, 0, 1); + GameObject right_leg = mgr.new_object("rightLeg", "person", Vector2{1, 1}, 0, 1); + GameObject left_leg = mgr.new_object("leftLeg", "person", Vector2{1, 1}, 0, 1); + GameObject right_foot = mgr.new_object("rightFoot", "person", Vector2{2, 2}, 0, 1); + GameObject left_foot = mgr.new_object("leftFoot", "person", Vector2{2, 2}, 0, 1); // Set the parent of each GameObject right_foot.set_parent(right_leg); diff --git a/src/example/scene_manager.cpp b/src/example/scene_manager.cpp index 62720eb..accec7d 100644 --- a/src/example/scene_manager.cpp +++ b/src/example/scene_manager.cpp @@ -16,12 +16,9 @@ public: 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); + 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); } }; @@ -31,14 +28,10 @@ public: 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); + 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); } }; diff --git a/src/test/PhysicsTest.cpp b/src/test/PhysicsTest.cpp index edb76e9..1e37c26 100644 --- a/src/test/PhysicsTest.cpp +++ b/src/test/PhysicsTest.cpp @@ -49,8 +49,7 @@ public: TEST_F(PhysicsTest, gravity) { Config::get_instance().physics.gravity = 1; ComponentManager & mgr = this->component_manager; - vector> transforms - = mgr.get_components_by_id(0); + vector> transforms = mgr.get_components_by_id(0); const Transform & transform = transforms.front().get(); ASSERT_FALSE(transforms.empty()); EXPECT_EQ(transform.position.y, 0); @@ -64,8 +63,7 @@ TEST_F(PhysicsTest, gravity) { TEST_F(PhysicsTest, max_velocity) { ComponentManager & mgr = this->component_manager; - vector> rigidbodies - = mgr.get_components_by_id(0); + vector> rigidbodies = mgr.get_components_by_id(0); Rigidbody & rigidbody = rigidbodies.front().get(); ASSERT_FALSE(rigidbodies.empty()); EXPECT_EQ(rigidbody.data.linear_velocity.y, 0); @@ -88,11 +86,9 @@ TEST_F(PhysicsTest, max_velocity) { TEST_F(PhysicsTest, movement) { Config::get_instance().physics.gravity = 0; ComponentManager & mgr = this->component_manager; - vector> rigidbodies - = mgr.get_components_by_id(0); + vector> rigidbodies = mgr.get_components_by_id(0); Rigidbody & rigidbody = rigidbodies.front().get(); - vector> transforms - = mgr.get_components_by_id(0); + vector> transforms = mgr.get_components_by_id(0); const Transform & transform = transforms.front().get(); ASSERT_FALSE(rigidbodies.empty()); ASSERT_FALSE(transforms.empty()); -- cgit v1.2.3