diff options
| author | JAROWMR <jarorutjes07@gmail.com> | 2025-01-08 13:15:06 +0100 | 
|---|---|---|
| committer | JAROWMR <jarorutjes07@gmail.com> | 2025-01-08 13:15:06 +0100 | 
| commit | c001bfe4e82cecc880700b6f2a434371d818a473 (patch) | |
| tree | e54bdf1c37176a32b5933410051c35f6ef47fc2a | |
| parent | f1788548fdc8491442e199c88058c223f506d42c (diff) | |
| parent | 8ea70b897805ff84113758d45a4c5c1a171a77bd (diff) | |
Merge branch 'loek/replay' of github.com:lonkaars/crepe into jaro/game
| -rw-r--r-- | src/crepe/api/Animator.cpp | 17 | ||||
| -rw-r--r-- | src/crepe/api/Animator.h | 6 | ||||
| -rw-r--r-- | src/crepe/api/Sprite.cpp | 15 | ||||
| -rw-r--r-- | src/crepe/api/Sprite.h | 10 | 
4 files changed, 24 insertions, 24 deletions
| diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp index f9a283e..c558d86 100644 --- a/src/crepe/api/Animator.cpp +++ b/src/crepe/api/Animator.cpp @@ -1,3 +1,4 @@ +  #include "util/dbg.h"  #include "Animator.h" @@ -5,7 +6,6 @@  #include "Sprite.h"  using namespace crepe; -using namespace std;  Animator::Animator(  	game_object_id_t id, Sprite & spritesheet, const ivec2 & single_frame_size, @@ -57,18 +57,3 @@ void Animator::next_anim() {  	ctx.row = ++ctx.row % this->grid_size.x;  	this->spritesheet.mask.x = ctx.row * this->spritesheet.mask.w;  } - -unique_ptr<Component> Animator::save() const { -	return unique_ptr<Component>(new Animator(*this)); -} - -void Animator::restore(const Component & snapshot) { -	*this = static_cast<const Animator &>(snapshot); -} - -Animator & Animator::operator=(const Animator & snapshot) { -	this->data = snapshot.data; -	this->elapsed_time = snapshot.elapsed_time; -	this->frame = snapshot.frame; -	return *this; -} diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h index d1f49c4..95539d3 100644 --- a/src/crepe/api/Animator.h +++ b/src/crepe/api/Animator.h @@ -108,12 +108,6 @@ private:  	//! Uses the spritesheet  	friend AnimatorSystem; - -protected: -	virtual std::unique_ptr<Component> save() const; -	Animator(const Animator &) = default; -	virtual void restore(const Component & snapshot); -	virtual Animator & operator=(const Animator &);  };  } // namespace crepe 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<Component> Sprite::save() const { +	return unique_ptr<Component>(new Sprite(*this)); +} + +void Sprite::restore(const Component & snapshot) { +	*this = static_cast<const Sprite &>(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<Component> save() const; +	Sprite(const Sprite &) = default; +	virtual void restore(const Component & snapshot); +	virtual Sprite & operator=(const Sprite &);  };  } // namespace crepe |