From: Mathnerd314 Date: Thu, 21 Jan 2010 00:09:05 +0000 (+0000) Subject: Matt's patch for Stalactite shaking (bug 543) X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=aa4c38aaae18ca53f02162298ee3dfd0557fa5ef;p=supertux.git Matt's patch for Stalactite shaking (bug 543) SVN-Revision: 6267 --- 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