From 94f2066c0ae3b60180976240201ecf3b081e5eaf Mon Sep 17 00:00:00 2001 From: mathnerd314 Date: Thu, 21 Jan 2010 00:09:05 +0000 Subject: [PATCH] Matt's patch for Stalactite shaking (bug 543) git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6267 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- src/badguy/stalactite.cpp | 6 ++++-- src/badguy/stalactite.hpp | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/badguy/stalactite.cpp b/src/badguy/stalactite.cpp index 6742c7346..20eea8c59 100644 --- a/src/badguy/stalactite.cpp +++ b/src/badguy/stalactite.cpp @@ -28,7 +28,8 @@ static const float SHAKE_RANGE_Y = 400; Stalactite::Stalactite(const Reader& lisp) : BadGuy(lisp, "images/creatures/stalactite/stalactite.sprite", LAYER_TILES - 1), timer(), - state(STALACTITE_HANGING) + state(STALACTITE_HANGING), + shake_delta() { countMe = false; set_colgroup_active(COLGROUP_TOUCHABLE); @@ -49,6 +50,7 @@ Stalactite::active_update(float elapsed_time) } } } else if(state == STALACTITE_SHAKING) { + shake_delta = Vector(systemRandom.rand(-3,3), 0); if(timer.check()) { state = STALACTITE_FALLING; physic.enable_gravity(true); @@ -130,7 +132,7 @@ Stalactite::draw(DrawingContext& context) } if(state == STALACTITE_SHAKING) { - sprite->draw(context, get_pos() + Vector(systemRandom.rand(-3,3), 0), layer); + sprite->draw(context, get_pos() + shake_delta, layer); } else { sprite->draw(context, get_pos(), layer); } diff --git a/src/badguy/stalactite.hpp b/src/badguy/stalactite.hpp index b396fbc6c..1835d936b 100644 --- a/src/badguy/stalactite.hpp +++ b/src/badguy/stalactite.hpp @@ -46,6 +46,7 @@ protected: protected: Timer timer; StalactiteState state; + Vector shake_delta; }; #endif -- 2.11.0