diff options
author | Philipp Sehmisch <crush@themanaworld.org> | 2009-01-25 03:36:13 +0100 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-01-25 00:00:10 -0700 |
commit | edd500dd27bb648840abfe1cecb0767d7b2ba3ae (patch) | |
tree | 7500a0c6906b3901677d4010b9a0dc845740c882 /src | |
parent | 20adf0056f3b22bf9628daed0967151918f75ad2 (diff) | |
download | mana-edd500dd27bb648840abfe1cecb0767d7b2ba3ae.tar.gz mana-edd500dd27bb648840abfe1cecb0767d7b2ba3ae.tar.bz2 mana-edd500dd27bb648840abfe1cecb0767d7b2ba3ae.tar.xz mana-edd500dd27bb648840abfe1cecb0767d7b2ba3ae.zip |
Fixed performance hickups caused by animations due to buggy tick timer. A tad less performant than the intended solution but at least it is constantly so.
Diffstat (limited to 'src')
-rw-r--r-- | src/engine.cpp | 1 | ||||
-rw-r--r-- | src/map.cpp | 23 | ||||
-rw-r--r-- | src/map.h | 6 |
3 files changed, 18 insertions, 12 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index 2a37d888..ab13450e 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -157,5 +157,6 @@ void Engine::logic() { beingManager->logic(); particleEngine->update(); + mCurrentMap->update(); gui->logic(); } diff --git a/src/map.cpp b/src/map.cpp index 01844409..57b79ef4 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -64,7 +64,6 @@ struct Location TileAnimation::TileAnimation(Animation *ani): mAnimation(ani), - mLastUpdate(tick_time), mLastImage(NULL) { } @@ -72,8 +71,7 @@ TileAnimation::TileAnimation(Animation *ani): void TileAnimation::update() { //update animation - mAnimation.update(tick_time - mLastUpdate); - mLastUpdate = tick_time; + mAnimation.update(1); // exchange images Image *img = mAnimation.getCurrentImage(); @@ -231,6 +229,17 @@ bool spriteCompare(const Sprite *a, const Sprite *b) return a->getPixelY() < b->getPixelY(); } +void Map::update() +{ + //update animated tiles + for (std::map<int, TileAnimation*>::iterator iAni = mTileAnimations.begin(); + iAni != mTileAnimations.end(); + iAni++) + { + iAni->second->update(); + } +} + void Map::draw(Graphics *graphics, int scrollX, int scrollY) { int endPixelY = graphics->getHeight() + scrollY + mTileHeight - 1; @@ -246,14 +255,6 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY) // Make sure sprites are sorted mSprites.sort(spriteCompare); - //update animated tiles - for (std::map<int, TileAnimation*>::iterator iAni = mTileAnimations.begin(); - iAni != mTileAnimations.end(); - iAni++) - { - iAni->second->update(); - } - // draw the game world Layers::const_iterator layeri = mLayers.begin(); for (; layeri != mLayers.end(); ++layeri) @@ -78,7 +78,6 @@ class TileAnimation private: std::list<std::pair<MapLayer*, int> > mAffected; SimpleAnimation mAnimation; - int mLastUpdate; Image* mLastImage; }; @@ -160,6 +159,11 @@ class Map : public Properties void initializeOverlays(); /** + * Updates animations. Called every game tick. + */ + void update(); + + /** * Draws the map to the given graphics output. This method draws all * layers, sprites and overlay effects. * |