diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-11 14:38:08 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-11 14:38:08 +0100 |
commit | 68c6e53f195677a3f91deb1526275fd38e00341d (patch) | |
tree | 2c310c8fa699dc88d2e609f3bd38bc9681aaca83 | |
parent | 2bcd6ece912ab0a140f9d925718e8787879d1ed7 (diff) |
make format
-rw-r--r-- | src/crepe/api/Animator.cpp | 3 | ||||
-rw-r--r-- | src/crepe/api/LoopManager.h | 6 | ||||
-rw-r--r-- | src/crepe/api/LoopTimer.cpp | 4 | ||||
-rw-r--r-- | src/crepe/api/Sprite.h | 1 | ||||
-rw-r--r-- | src/crepe/facade/SDLContext.cpp | 3 | ||||
-rw-r--r-- | src/crepe/facade/Texture.cpp | 16 | ||||
-rw-r--r-- | src/example/sound.cpp | 54 | ||||
-rw-r--r-- | src/test/ResourceManagerTest.cpp | 4 |
8 files changed, 17 insertions, 74 deletions
diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp index 123f0e7..644363e 100644 --- a/src/crepe/api/Animator.cpp +++ b/src/crepe/api/Animator.cpp @@ -20,7 +20,8 @@ Animator::Animator(game_object_id_t id, Sprite & spritesheet, const ivec2 & sing this->spritesheet.mask.x = 0; this->spritesheet.mask.y = 0; - this->spritesheet.aspect_ratio = static_cast<float>(single_frame_size.x) / single_frame_size.y; + this->spritesheet.aspect_ratio + = static_cast<float>(single_frame_size.x) / single_frame_size.y; } Animator::~Animator() { dbg_trace(); } diff --git a/src/crepe/api/LoopManager.h b/src/crepe/api/LoopManager.h index 7389124..bf1a9f9 100644 --- a/src/crepe/api/LoopManager.h +++ b/src/crepe/api/LoopManager.h @@ -103,12 +103,12 @@ private: //! Save manager instance SaveManager save_manager{mediator}; - SDLContext sdl_context {mediator}; + SDLContext sdl_context{mediator}; - ResourceManager res_man {mediator}; + ResourceManager res_man{mediator}; //! Loop timer \todo no more singletons! - LoopTimer loop_timer {mediator}; + LoopTimer loop_timer{mediator}; private: /** diff --git a/src/crepe/api/LoopTimer.cpp b/src/crepe/api/LoopTimer.cpp index d6bf451..56e48d3 100644 --- a/src/crepe/api/LoopTimer.cpp +++ b/src/crepe/api/LoopTimer.cpp @@ -8,8 +8,8 @@ using namespace crepe; -LoopTimer::LoopTimer(Mediator & mediator) : Manager(mediator){ - dbg_trace(); +LoopTimer::LoopTimer(Mediator & mediator) : Manager(mediator) { + dbg_trace(); mediator.timer = *this; } diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h index 14a873b..a2409c2 100644 --- a/src/crepe/api/Sprite.h +++ b/src/crepe/api/Sprite.h @@ -92,7 +92,6 @@ private: //! Reads the all the variables plus the mask friend class AnimatorSystem; - /** * \aspect_ratio the ratio of the sprite image * diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index 0566ecf..1699b53 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -233,7 +233,8 @@ SDL_FRect SDLContext::get_dst_rect(const DestinationRectangleData & ctx) const { const Sprite::Data & data = ctx.sprite.data; - float aspect_ratio = (ctx.sprite.aspect_ratio == 0) ? ctx.texture.get_ratio() : ctx.sprite.aspect_ratio; + float aspect_ratio + = (ctx.sprite.aspect_ratio == 0) ? ctx.texture.get_ratio() : ctx.sprite.aspect_ratio; vec2 size = data.size; if (data.size.x == 0 && data.size.y != 0) { diff --git a/src/crepe/facade/Texture.cpp b/src/crepe/facade/Texture.cpp index 7224cb8..b63403d 100644 --- a/src/crepe/facade/Texture.cpp +++ b/src/crepe/facade/Texture.cpp @@ -1,6 +1,6 @@ #include "../util/Log.h" -#include "manager/Mediator.h" #include "facade/SDLContext.h" +#include "manager/Mediator.h" #include "Resource.h" #include "Texture.h" @@ -9,7 +9,7 @@ using namespace crepe; using namespace std; -Texture::Texture(const Asset & src, Mediator & mediator) : Resource(src, mediator){ +Texture::Texture(const Asset & src, Mediator & mediator) : Resource(src, mediator) { dbg_trace(); SDLContext & ctx = mediator.sdl_context; this->texture = ctx.texture_from_path(src.get_path()); @@ -22,13 +22,7 @@ Texture::~Texture() { this->texture.reset(); } -const ivec2 & Texture::get_size() const noexcept{ - return this->size; -} -const float & Texture::get_ratio() const noexcept{ - return this->aspect_ratio; -} +const ivec2 & Texture::get_size() const noexcept { return this->size; } +const float & Texture::get_ratio() const noexcept { return this->aspect_ratio; } -SDL_Texture * Texture::get_img() const noexcept{ - return this->texture.get(); -} +SDL_Texture * Texture::get_img() const noexcept { return this->texture.get(); } diff --git a/src/example/sound.cpp b/src/example/sound.cpp deleted file mode 100644 index a9b0930..0000000 --- a/src/example/sound.cpp +++ /dev/null @@ -1,54 +0,0 @@ - - -#include "api/Asset.h" -#include "api/AudioSource.h" -#include "api/BehaviorScript.h" -#include "api/Camera.h" -#include "api/GameObject.h" -#include "api/LoopManager.h" -#include "api/Scene.h" -#include "api/Script.h" -#include "manager/ComponentManager.h" -#include "types.h" -#include <string> - -using namespace crepe; - - -class ScriptTest : public Script { - void init(){ - auto & audio = this->get_component<AudioSource>(); - audio.play(); - } - void update(){ - } -}; - - -class TestSound : public Scene { -public: - void load_scene(){ - Mediator & mediator = this->mediator; - ComponentManager & mgr = mediator.component_manager; - - GameObject obj = mgr.new_object("SOUND"); - GameObject cam = mgr.new_object("cam"); - cam.add_component<Camera>(ivec2{100,100},vec2{100,100}, Camera::Data{}); - - Asset asset{"asset/audio/sample.ogg"}; - auto & test = obj.add_component<AudioSource>(asset); - obj.add_component<BehaviorScript>().set_script<ScriptTest>(); - - - } - - std::string get_name() const { return "TestScene"; }; - -}; - -int main(){ - LoopManager engine; - engine.add_scene<TestSound>(); - engine.start(); - return 0; -} diff --git a/src/test/ResourceManagerTest.cpp b/src/test/ResourceManagerTest.cpp index e040f54..965eeab 100644 --- a/src/test/ResourceManagerTest.cpp +++ b/src/test/ResourceManagerTest.cpp @@ -31,7 +31,9 @@ public: public: const unsigned instance; - TestResource(const Asset & src, Mediator & mediator) : Resource(src, mediator), instance(this->instances++) {} + TestResource(const Asset & src, Mediator & mediator) + : Resource(src, mediator), + instance(this->instances++) {} ~TestResource() { this->instances--; } bool operator==(const TestResource & other) const { return this->instance == other.instance; |