diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/crepe/api/Color.cpp | 1 | ||||
-rw-r--r-- | src/crepe/api/Color.h | 1 | ||||
-rw-r--r-- | src/crepe/api/Sprite.cpp | 13 | ||||
-rw-r--r-- | src/crepe/api/Sprite.h | 10 | ||||
-rw-r--r-- | src/test/AudioTest.cpp | 9 |
5 files changed, 32 insertions, 2 deletions
diff --git a/src/crepe/api/Color.cpp b/src/crepe/api/Color.cpp index 1374198..d0e3b35 100644 --- a/src/crepe/api/Color.cpp +++ b/src/crepe/api/Color.cpp @@ -11,3 +11,4 @@ const Color Color::CYAN {0x00, 0xff, 0xff}; const Color Color::YELLOW {0xff, 0xff, 0x00}; const Color Color::MAGENTA {0xff, 0x00, 0xff}; const Color Color::GREY {0x80, 0x80, 0x80}; +const Color Color::GOLD {249, 205, 91}; diff --git a/src/crepe/api/Color.h b/src/crepe/api/Color.h index 22c0c43..dbfd0ed 100644 --- a/src/crepe/api/Color.h +++ b/src/crepe/api/Color.h @@ -19,6 +19,7 @@ struct Color { static const Color YELLOW; static const Color BLACK; static const Color GREY; + static const Color GOLD; }; } // namespace crepe diff --git a/src/crepe/api/Sprite.cpp b/src/crepe/api/Sprite.cpp index 0107c7b..3c77e2e 100644 --- a/src/crepe/api/Sprite.cpp +++ b/src/crepe/api/Sprite.cpp @@ -19,3 +19,16 @@ 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 diff --git a/src/test/AudioTest.cpp b/src/test/AudioTest.cpp index 3844c73..e548221 100644 --- a/src/test/AudioTest.cpp +++ b/src/test/AudioTest.cpp @@ -60,6 +60,8 @@ TEST_F(AudioTest, Play) { InSequence seq; EXPECT_CALL(context, play(_)).Times(0); + EXPECT_CALL(context, set_loop(_, _)).Times(0); + EXPECT_CALL(context, set_volume(_, _)).Times(0); component.play(); } @@ -67,6 +69,8 @@ TEST_F(AudioTest, Play) { InSequence seq; EXPECT_CALL(context, play(_)).Times(1); + EXPECT_CALL(context, set_loop(_, _)).Times(1); + EXPECT_CALL(context, set_volume(_, _)).Times(1); system.fixed_update(); } } @@ -146,6 +150,9 @@ TEST_F(AudioTest, PlayOnActive) { InSequence seq; EXPECT_CALL(context, play(_)).Times(1); + EXPECT_CALL(context, set_loop(_, _)).Times(1); + EXPECT_CALL(context, set_volume(_, _)).Times(1); + component.active = true; system.fixed_update(); } @@ -156,6 +163,8 @@ TEST_F(AudioTest, PlayImmediately) { component.play(); EXPECT_CALL(context, play(_)).Times(1); + EXPECT_CALL(context, set_volume(_, _)).Times(1); + EXPECT_CALL(context, set_loop(_, _)).Times(1); system.fixed_update(); } |