summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTametomo <irarice@gmail.com>2009-04-15 20:08:21 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-15 20:10:13 +0200
commit9c2139f8b11f554cbc884bbb52278399e6994074 (patch)
treeb9b71740adb94bf9fd37d75dfb750cf34312806d /src
parentdcca13ea04fd7aa9b1539c1325cd0e465f9b545a (diff)
downloadmana-9c2139f8b11f554cbc884bbb52278399e6994074.tar.gz
mana-9c2139f8b11f554cbc884bbb52278399e6994074.tar.bz2
mana-9c2139f8b11f554cbc884bbb52278399e6994074.tar.xz
mana-9c2139f8b11f554cbc884bbb52278399e6994074.zip
Moved tile animations outside of the clock time polling loop. There's no
need to poll the CPU for them, when they already can compensate for missed clock ticks. Signed-off-by: Tametomo <irarice@gmail.com> Signed-off-by: Bjørn Lindeijer <bjorn@lindeijer.nl>
Diffstat (limited to 'src')
-rw-r--r--src/engine.cpp2
-rw-r--r--src/game.cpp6
-rw-r--r--src/map.cpp10
-rw-r--r--src/map.h6
4 files changed, 12 insertions, 12 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index 61293339..a0e475f6 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -148,7 +148,5 @@ void Engine::logic()
{
beingManager->logic();
particleEngine->update();
- if (mCurrentMap)
- mCurrentMap->update();
gui->logic();
}
diff --git a/src/game.cpp b/src/game.cpp
index 750725db..2ee4ad13 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -41,6 +41,7 @@
#include "keyboardconfig.h"
#include "localplayer.h"
#include "log.h"
+#include "map.h"
#include "npc.h"
#include "particle.h"
#include "player_relations.h"
@@ -95,8 +96,6 @@
#include "utils/gettext.h"
-class Map;
-
std::string map_path;
bool done = false;
@@ -473,6 +472,9 @@ void Game::logic()
while (!done)
{
+ if (Map *map = engine->getCurrentMap())
+ map->update(get_elapsed_time(gameTime));
+
// Handle all necessary game logic
while (get_elapsed_time(gameTime) > 0)
{
diff --git a/src/map.cpp b/src/map.cpp
index 0dc4759e..472c136f 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -75,13 +75,13 @@ TileAnimation::~TileAnimation()
delete mAnimation;
}
-void TileAnimation::update()
+void TileAnimation::update(int ticks)
{
if (!mAnimation)
return;
- //update animation
- mAnimation->update(1);
+ // update animation
+ mAnimation->update(ticks);
// exchange images
Image *img = mAnimation->getCurrentImage();
@@ -248,14 +248,14 @@ bool spriteCompare(const Sprite *a, const Sprite *b)
return a->getPixelY() < b->getPixelY();
}
-void Map::update()
+void Map::update(int ticks)
{
//update animated tiles
for (std::map<int, TileAnimation*>::iterator iAni = mTileAnimations.begin();
iAni != mTileAnimations.end();
iAni++)
{
- iAni->second->update();
+ iAni->second->update(ticks);
}
}
diff --git a/src/map.h b/src/map.h
index 09bed293..c49ebb12 100644
--- a/src/map.h
+++ b/src/map.h
@@ -73,7 +73,7 @@ class TileAnimation
public:
TileAnimation(Animation *ani);
~TileAnimation();
- void update();
+ void update(int ticks = 1);
void addAffectedTile(MapLayer *layer, int index)
{ mAffected.push_back(std::make_pair(layer, index)); }
private:
@@ -169,9 +169,9 @@ class Map : public Properties
void initializeOverlays();
/**
- * Updates animations. Called every game tick.
+ * Updates animations. Called as needed.
*/
- void update();
+ void update(int ticks = 1);
/**
* Draws the map to the given graphics output. This method draws all