ScummVM API documentation
TileMap.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of HPL1 Engine.
26  */
27 
28 #ifndef HPL_TILEMAP_H
29 #define HPL_TILEMAP_H
30 
31 #include "common/array.h"
32 #include "hpl1/engine/graphics/Graphics.h"
33 #include "hpl1/engine/math/MathTypes.h"
34 #include "hpl1/engine/scene/Camera2D.h"
35 #include "hpl1/engine/scene/TileLayer.h"
36 #include "hpl1/engine/scene/TileMapIt.h"
37 #include "hpl1/engine/scene/TileSet.h"
38 
39 namespace hpl {
40 
41 typedef Common::Array<cTileSet *> tTileSetVec;
42 typedef tTileSetVec::iterator tTileSetVecIt;
43 
44 typedef Common::Array<cTileLayer *> tTileLayerVec;
45 typedef tTileLayerVec::iterator tTileLayerVecIt;
46 
47 class cTileMap {
48  friend class cTileMapRectIt;
49  friend class cTileMapLineIt;
50 
51 public:
52  cTileMap(cVector2l avSize, float afTileSize, cGraphics *apGraphics, cResources *apResources);
53  ~cTileMap();
54 
55  const cVector2l &GetSize() { return mvSize; }
56  float GetTileSize() { return mfTileSize; }
57 
58  int GetTileNeighbours4Dir(int alTileNum, int alLayer, bool *avDir);
59 
60  void AddTileSet(cTileSet *apSet) { mvTileSet.push_back(apSet); }
61  cTileSet *GetTileSet(int alNum) { return mvTileSet[alNum]; }
62 
63  void AddTileLayerFront(cTileLayer *apLayer);
64  void AddTileLayerBack(cTileLayer *apLayer) { mvTileLayer.push_back(apLayer); }
65 
66  cTileLayer *GetTileLayer(int alNum) { return mvTileLayer[alNum]; }
67  int GetTileLayerNum() { return (int)mvTileLayer.size(); }
68 
69  iTileMapIt *GetRectIterator(const cRect2f &aRect, int alLayer);
70  iTileMapIt *GetLineIterator(const cVector2f &avStart, const cVector2f &avEnd, int alLayer);
71 
72  void Render(cCamera2D *apCam);
73 
74  cTile *GetScreenTile(cVector2f avPos, int alLayer, cCamera2D *apCam);
75  void SetScreenTileData(cVector2f avPos, int alLayer, cCamera2D *apCam, int alTileSet, int alTileNum);
76  void SetScreenTileAngle(cVector2f avPos, int alLayer, cCamera2D *apCam, int alAngle);
77 
78  cTile *GetWorldTile(cVector2f avPos, int alLayer);
79  cVector2f GetWorldPos(cVector2f avScreenPos, cCamera2D *apCam);
80 
81  void SetShadowLayer(int alShadowLayer) { mlShadowLayer = alShadowLayer; }
82  int GetShadowLayer() { return mlShadowLayer; }
83 
84 private:
85  cGraphics *mpGraphics;
86  cResources *mpResources;
87 
88  tTileSetVec mvTileSet;
89  tTileLayerVec mvTileLayer;
90  int mlShadowLayer;
91 
92  cVector2l mvSize;
93  float mfTileSize;
94  int mlCurrentLayer;
95 
96  inline void RenderTileData(cTile *apTile, int alLayer);
97 };
98 
99 } // namespace hpl
100 
101 #endif // HPL_TILEMAP_H
Definition: AI.h:36
Definition: Tile.h:41
Definition: TileMapLineIt.h:37
Definition: TileSet.h:48
T * iterator
Definition: array.h:54
void push_back(const T &element)
Definition: array.h:180
Definition: TileMapRectIt.h:37
Definition: TileMapIt.h:35
size_type size() const
Definition: array.h:315
Definition: Resources.h:160
Definition: TileLayer.h:46
Definition: Graphics.h:46
Definition: Camera2D.h:38
Definition: TileMap.h:47