From 394989d94081cbc462ba7d567fc88d0c4dff8134 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Tue, 6 Jan 2009 14:33:20 +0100 Subject: Added support for animated tiles. --- src/map.h | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'src/map.h') 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; @@ -63,6 +65,23 @@ struct MetaTile bool walkable; /**< Can beings walk on this tile */ }; +/** + * 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 > mAffected; + SimpleAnimation mAnimation; + int mLastUpdate; + Image* mLastImage; +}; + /** * A map layer. Stores a grid of tiles and their offset, and implements layer * rendering. @@ -87,6 +106,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. */ @@ -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 particleEffects; + + std::map mTileAnimations; }; #endif -- cgit v1.2.3-70-g09d2