]> git.localhorst.tv Git - l2e.git/blobdiff - src/map/Area.cpp
added basic map classes
[l2e.git] / src / map / Area.cpp
diff --git a/src/map/Area.cpp b/src/map/Area.cpp
new file mode 100644 (file)
index 0000000..a1ae680
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Area.cpp
+ *
+ *  Created on: Sep 26, 2012
+ *      Author: holy
+ */
+
+#include "Area.h"
+
+#include "Tile.h"
+#include "../graphics/Sprite.h"
+
+using geometry::Vector;
+
+namespace map {
+
+Area::Area()
+: tiles(0)
+, numTiles(0)
+, width(0) {
+
+}
+
+void Area::Render(SDL_Surface *dest, const graphics::Sprite *tileset, const Vector<int> &inOffset) const {
+       for (int i(0); i < numTiles; ++i) {
+               Vector<int> offset(
+                               inOffset.X() + (i % width) * tileset->Width(),
+                               inOffset.Y() + (i / width) * tileset->Height());
+               const Tile &tile(tiles[i]);
+               tileset->Draw(dest, offset, tile.Offset().X(), tile.Offset().Y());
+       }
+}
+
+}