From 297d621987c224db26eadfb9bde9235741387496 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 12 Dec 2024 19:46:15 +0100 Subject: more cleanup + script utilities --- src/crepe/api/Sprite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/crepe/api/Sprite.cpp') diff --git a/src/crepe/api/Sprite.cpp b/src/crepe/api/Sprite.cpp index ba684ba..0107c7b 100644 --- a/src/crepe/api/Sprite.cpp +++ b/src/crepe/api/Sprite.cpp @@ -1,6 +1,6 @@ #include -#include "../util/Log.h" +#include "../util/dbg.h" #include "api/Asset.h" #include "Component.h" -- cgit v1.2.3 From 8ea70b897805ff84113758d45a4c5c1a171a77bd Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 8 Jan 2025 13:14:37 +0100 Subject: implement sprite replay --- src/crepe/api/Sprite.cpp | 15 +++++++++++++++ src/crepe/api/Sprite.h | 10 ++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'src/crepe/api/Sprite.cpp') diff --git a/src/crepe/api/Sprite.cpp b/src/crepe/api/Sprite.cpp index 0107c7b..2919857 100644 --- a/src/crepe/api/Sprite.cpp +++ b/src/crepe/api/Sprite.cpp @@ -19,3 +19,18 @@ Sprite::Sprite(game_object_id_t id, const Asset & texture, const Sprite::Data & } Sprite::~Sprite() { dbg_trace(); } + +unique_ptr Sprite::save() const { + return unique_ptr(new Sprite(*this)); +} + +void Sprite::restore(const Component & snapshot) { + *this = static_cast(snapshot); +} + +Sprite & Sprite::operator=(const Sprite & snapshot) { + this->active = snapshot.active; + this->data = snapshot.data; + this->mask = snapshot.mask; + return *this; +} diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h index a3fc319..3565bed 100644 --- a/src/crepe/api/Sprite.h +++ b/src/crepe/api/Sprite.h @@ -42,10 +42,10 @@ public: FlipSettings flip; //! Layer sorting level of the sprite - const int sorting_in_layer = 0; + int sorting_in_layer = 0; //! Order within the sorting layer - const int order_in_layer = 0; + int order_in_layer = 0; /** * \brief width and height of the sprite in game units @@ -119,6 +119,12 @@ private: //! Render area of the sprite this will also be adjusted by the AnimatorSystem if an Animator // object is present in GameObject. this is in sprite pixels Rect mask; + +protected: + virtual std::unique_ptr save() const; + Sprite(const Sprite &) = default; + virtual void restore(const Component & snapshot); + virtual Sprite & operator=(const Sprite &); }; } // namespace crepe -- cgit v1.2.3 From b92b3b830dc53ecc2accf8472a8e4ce8be2e19dc Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 8 Jan 2025 14:49:09 +0100 Subject: `make format` --- game/Random.cpp | 1 - game/Random.h | 2 -- src/crepe/api/Sprite.cpp | 4 +--- 3 files changed, 1 insertion(+), 6 deletions(-) (limited to 'src/crepe/api/Sprite.cpp') diff --git a/game/Random.cpp b/game/Random.cpp index 59be3c5..ace6245 100644 --- a/game/Random.cpp +++ b/game/Random.cpp @@ -25,4 +25,3 @@ unsigned Random::u(unsigned upper, unsigned lower) { unsigned x = rand() % range; return x + lower; } - diff --git a/game/Random.h b/game/Random.h index cf05e87..8af9669 100644 --- a/game/Random.h +++ b/game/Random.h @@ -6,6 +6,4 @@ public: static double d(double upper = 1.0, double lower = 0.0); static int i(int upper, int lower = 0); static unsigned u(unsigned upper, unsigned lower = 0); - }; - diff --git a/src/crepe/api/Sprite.cpp b/src/crepe/api/Sprite.cpp index 2919857..3c77e2e 100644 --- a/src/crepe/api/Sprite.cpp +++ b/src/crepe/api/Sprite.cpp @@ -20,9 +20,7 @@ Sprite::Sprite(game_object_id_t id, const Asset & texture, const Sprite::Data & Sprite::~Sprite() { dbg_trace(); } -unique_ptr Sprite::save() const { - return unique_ptr(new Sprite(*this)); -} +unique_ptr Sprite::save() const { return unique_ptr(new Sprite(*this)); } void Sprite::restore(const Component & snapshot) { *this = static_cast(snapshot); -- cgit v1.2.3