summaryrefslogtreecommitdiff
path: root/src/map.h
diff options
context:
space:
mode:
authorPhilipp Sehmisch <crush@themanaworld.org>2009-01-06 14:33:20 +0100
committerIra Rice <irarice@gmail.com>2009-01-06 10:48:20 -0700
commit394989d94081cbc462ba7d567fc88d0c4dff8134 (patch)
tree49c43dd2bcceb0cf204b13e7ed88132623910d2c /src/map.h
parent3e40c30cdd3a7b3942131fc8b72b268aa0e98f77 (diff)
downloadmana-client-394989d94081cbc462ba7d567fc88d0c4dff8134.tar.gz
mana-client-394989d94081cbc462ba7d567fc88d0c4dff8134.tar.bz2
mana-client-394989d94081cbc462ba7d567fc88d0c4dff8134.tar.xz
mana-client-394989d94081cbc462ba7d567fc88d0c4dff8134.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