From 91e2779891973cdbefc6e07ca3dee7a432a05112 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Mon, 14 Mar 2011 20:56:40 +0100 Subject: Implemented a screen shake effect system in the viewport class. The screen can either be "nudged" in a random direction with a specific intensity or you can define an exact x and y intensity, decay factor and duration. On a tmwAthena server an effect is triggered when the player character dies. A method for stopping all shake effects is also implemented, but not used yet. I added a netcode message for Manaserv to trigger an effect server-sided. Because our protocol has currently no way to transport floating point values, the decay is transported as a fixed point value with 4 decimals which is entirely sufficient for this purpose. --- src/gui/viewport.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/gui/viewport.h') diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 93e36b5b..f4db806b 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -29,6 +29,8 @@ #include +#include + class ActorSprite; class Being; class BeingPopup; @@ -153,6 +155,22 @@ class Viewport : public WindowContainer, public gcn::MouseListener, */ void hideBeingPopup(); + /** + * Makes the screen shake in a random direction + */ + void shakeScreen(int intensity); + + /** + * Makes the screen shake in a specific direction + */ + void shakeScreen(float x, float y, float decay = 0.95f, unsigned duration = 0); + + /** + * Stops all active screen shake effects + */ + void shakeScreenStop() + { mShakeEffects.clear(); } + void event(Channels channel, const Mana::Event &event); private: @@ -190,6 +208,16 @@ class Viewport : public WindowContainer, public gcn::MouseListener, float mPixelViewY; /**< Current viewpoint in pixels. */ int mShowDebugPath; /**< Show a path from player to pointer. */ + struct ShakeEffect + { + float x; + float y; + float decay; + unsigned duration; + }; + typedef std::list ShakeEffects; + ShakeEffects mShakeEffects; + bool mPlayerFollowMouse; int mLocalWalkTime; /**< Timestamp before the next walk can be sent. */ -- cgit v1.2.3-70-g09d2