]> git.localhorst.tv Git - l2e.git/blob - src/map/Map.cpp
added basic map classes
[l2e.git] / src / map / Map.cpp
1 /*
2  * Map.cpp
3  *
4  *  Created on: Sep 29, 2012
5  *      Author: holy
6  */
7
8 #include "Map.h"
9
10 #include "Area.h"
11 #include "../graphics/Sprite.h"
12
13 using geometry::Vector;
14
15 namespace map {
16
17 Map::Map()
18 : tileset(0)
19 , areas(0)
20 , numAreas(0)
21 , width(0) {
22
23 }
24
25
26 void Map::Render(SDL_Surface *dest, const Vector<int> &inOffset) const {
27         // TODO: skip invisible areas
28         for (int i(0); i < numAreas; ++i) {
29                 const Area &area(areas[i]);
30                 Vector<int> offset(
31                                 inOffset.X() + (i % width) * area.Width() * tileset->Width(),
32                                 inOffset.Y() + (i / width) * area.Height() * tileset->Height());
33                 area.Render(dest, tileset, offset);
34         }
35 }
36
37 }