// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
+
#include <config.h>
+#include "tile.hpp"
+
#include <math.h>
#include <assert.h>
#include <iostream>
#include <stdexcept>
#include "lisp/lisp.hpp"
-#include "tile.hpp"
#include "tile_set.hpp"
-#include "resources.hpp"
#include "timer.hpp"
#include "math/vector.hpp"
#include "video/drawing_context.hpp"
{
}
-Tile::Tile(const TileSet *new_tileset, Uint32 attributes, const ImageSpec& imagespec)
- : tileset(new_tileset), attributes(attributes), data(0), anim_fps(1)
+Tile::Tile(const TileSet *new_tileset, std::vector<std::string> images, Rect rect, Uint32 attributes, Uint32 data, float animfps)
+ : tileset(new_tileset), attributes(attributes), data(data), anim_fps(animfps)
{
- imagespecs.push_back(imagespec);
+ for(std::vector<std::string>::iterator i = images.begin(); i != images.end(); ++i) {
+ imagespecs.push_back(ImageSpec(*i, rect));
+ }
+ correct_attributes();
}
Tile::~Tile()
attributes |= SOLID | SLOPE;
}
- const lisp::Lisp* images = reader.get_lisp("images");
+ const lisp::Lisp* images;
+#ifdef DEBUG
+ images = reader.get_lisp("editor-images");
if(images)
parse_images(*images);
+ else {
+#endif /*DEBUG*/
+ images = reader.get_lisp("images");
+ if(images)
+ parse_images(*images);
+#ifdef DEBUG
+ }
+#endif /*DEBUG*/
+ correct_attributes();
return id;
}
context.draw_surface(images[0], pos, z_pos);
}
}
+
+void Tile::correct_attributes()
+{
+ //Fix little oddities in attributes (not many, currently...)
+ if(!(attributes & SOLID) && (attributes & SLOPE || attributes & UNISOLID)) {
+ attributes |= SOLID;
+ //But still be vocal about it
+ log_warning << "Tile with image " << imagespecs[0].file << " needs solid attribute." << std::endl;
+ }
+}