summaryrefslogtreecommitdiff
path: root/src/map.h
diff options
context:
space:
mode:
authorPhilipp Sehmisch <crush@themanaworld.org>2009-01-06 14:33:20 +0100
committerPhilipp Sehmisch <crush@themanaworld.org>2009-01-06 16:40:46 +0100
commit6b60673b0805fbab747924d1a0b6d9c66fc96f64 (patch)
treee40cc55a4d952bfb9bc89a41c3205c1d7bd90616 /src/map.h
parent090b4893a57a1b7e9c83f7db043843d35016fcff (diff)
downloadmana-6b60673b0805fbab747924d1a0b6d9c66fc96f64.tar.gz
mana-6b60673b0805fbab747924d1a0b6d9c66fc96f64.tar.bz2
mana-6b60673b0805fbab747924d1a0b6d9c66fc96f64.tar.xz
mana-6b60673b0805fbab747924d1a0b6d9c66fc96f64.zip
Added support for animated tiles.
Diffstat (limited to 'src/map.h')
-rw-r--r--src/map.h40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/map.h b/src/map.h
index 56183abf..81d0b629 100644
--- a/src/map.h
+++ b/src/map.h
@@ -28,6 +28,8 @@
#include "position.h"
#include "properties.h"
+#include "simpleanimation.h"
+
class AmbientOverlay;
class Graphics;
class Image;
@@ -64,6 +66,23 @@ struct MetaTile
};
/**
+ * Animation cycle of a tile image which changes the map accordingly.
+ */
+class TileAnimation
+{
+ public:
+ TileAnimation(Animation *ani);
+ void update();
+ void addAffectedTile(MapLayer *layer, int index)
+ { mAffected.push_back(std::make_pair(layer, index)); }
+ private:
+ std::list<std::pair<MapLayer*, int> > mAffected;
+ SimpleAnimation mAnimation;
+ int mLastUpdate;
+ Image* mLastImage;
+};
+
+/**
* A map layer. Stores a grid of tiles and their offset, and implements layer
* rendering.
*/
@@ -88,6 +107,11 @@ class MapLayer
void setTile(int x, int y, Image *img);
/**
+ * Set tile image with x + y * width already known.
+ */
+ void setTile(int index, Image *img) { mTiles[index] = img; }
+
+ /**
* Get tile image, with x and y in layer coordinates.
*/
Image *getTile(int x, int y) const;
@@ -225,8 +249,18 @@ class Map : public Properties
/**
* Initializes all added particle effects
*/
- void
- initializeParticleEffects(Particle* particleEngine);
+ void initializeParticleEffects(Particle* particleEngine);
+
+ /**
+ * Adds a tile animation to the map
+ */
+ void addAnimation(int gid, TileAnimation *animation)
+ { mTileAnimations[gid] = animation; }
+
+ /**
+ * Gets the tile animation for a specific gid
+ */
+ TileAnimation *getAnimationForGid(int gid);
private:
/**
@@ -270,6 +304,8 @@ class Map : public Properties
int y;
};
std::list<ParticleEffectData> particleEffects;
+
+ std::map<int, TileAnimation*> mTileAnimations;
};
#endif