support for centered text in scripts
[supertux.git] / src / object / tilemap.cpp
index 15c6125..8775418 100644 (file)
 #include <stdexcept>
 #include <cmath>
 
-#include "tilemap.h"
-#include "video/drawing_context.h"
-#include "level.h"
-#include "tile.h"
-#include "resources.h"
-#include "tile_manager.h"
-#include "lisp/lisp.h"
-#include "lisp/writer.h"
-#include "object_factory.h"
-#include "main.h"
+#include "tilemap.hpp"
+#include "video/drawing_context.hpp"
+#include "level.hpp"
+#include "tile.hpp"
+#include "resources.hpp"
+#include "tile_manager.hpp"
+#include "lisp/lisp.hpp"
+#include "lisp/writer.hpp"
+#include "object_factory.hpp"
+#include "main.hpp"
 
 TileMap::TileMap()
   : solid(false), speed(1), width(0), height(0), layer(LAYER_TILES),
@@ -281,4 +281,13 @@ TileMap::change_at(const Vector& pos, uint32_t newtile)
   change(int(pos.x)/32, int(pos.y)/32, newtile);
 }
 
+void
+TileMap::change_all(uint32_t oldtile, uint32_t newtile)
+{
+  for (size_t x = 0; x < get_width(); x++)
+    for (size_t y = 0; y < get_height(); y++) {
+      if (get_tile(x,y)->getID() == oldtile) change(x,y,newtile);
+    }
+}
+
 IMPLEMENT_FACTORY(TileMap, "tilemap");