ScummVM API documentation
TMXMap.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 * This code is based on the CRAB engine
24 *
25 * Copyright (c) Arvind Raja Yadav
26 *
27 * Licensed under MIT
28 *
29 */
30
31#ifndef CRAB_TMXMAP_H
32#define CRAB_TMXMAP_H
33
34#include "crab/LevelResult.h"
35#include "crab/Shape.h"
36#include "crab/XMLDoc.h"
37#include "crab/ai/spriteai.h"
38#include "crab/level/LevelExit.h"
39#include "crab/level/MusicArea.h"
40#include "crab/level/Stairs.h"
41#include "crab/TMX/TMXTileSet.h"
42
43namespace Crab {
44
45namespace TMX {
46// For TMX version 1.0, orthogonal maps only
47class TMXMap {
48protected:
49 // The actual dimensions of the level
50 int _w, _h;
51
52 // The area you can move in
53 Rect _areaWalk;
54
55 // The non-walk able areas in the level
56 Common::Array<Shape> _areaNowalk;
57
58 // The trigger rectangles in the level
59 Common::Array<Shape> _areaTrig;
60
61 // Stairs modify the player walking speed
63
64 // Music areas change the music if player collides with them
66
67 // Archived methods for loading poly lines in tiled
68 // void LoadPath(rapidxml::xml_node<char> *node);
69 // const Vector2i GetPoint(const Vector2i &ref, Common::String &x, Common::String &y);
70
71public:
72 // The exits to different levels
74
75 // The layer on top of which objects walk
76 uint _spriteLayer;
77
78 // Dimensions of the level in terms of tiles
79 int _tileRows, _tileCols;
80
81 // Dimensions of the level in terms of pathfinding grid cells (SZ)
82 int _pathRows, _pathCols;
83
84 // The width and height of tiles
85 Vector2i _tileSize;
86
87 // The width and height of pathfinding grid cells (SZ)
88 Vector2i _pathSize;
89
90 // The layers of tiles in the level
92
93 // The props in the level
95
96 PathfindingGrid *_grid; // The grid of graph nodes used for navigating.
97
98 // Movement costs
99 struct {
100 int _open, _noWalk, _stairs;
101 } _movementCosts;
102
103 TMXMap();
104 ~TMXMap() {}
105
106 void reset();
107 void load(const Common::Path &path, const Common::String &filename);
108
109 void drawDebug(const Rect &camera);
110
111 bool insideWalk(const Rect &boundingBox);
112 bool insideWalk(const Vector2i &pos);
113
114 bool insideNoWalk(const Vector2i &pos);
115 void collideWithNoWalk(const Rect boundingBox, Common::List<CollisionData> &colliders);
116
117 bool collideWithExit(const Rect rect, LevelResult &res);
118 bool collideWithStairs(const Rect rect, Vector2f &velMod);
119 bool collideWithMusic(const Rect rect, pyrodactyl::level::MusicInfo &music);
120
121 bool collideWithTrigger(const Rect rect, int index);
122 void collideWithTrigger(const Rect rect, Common::Array<int> &collisionTable);
123
124 int w() {
125 return _w;
126 }
127
128 int h() {
129 return _h;
130 }
131
132 const Rect &areaWalk() const {
133 return _areaWalk;
134 }
135
136 const Common::Array<Shape> &areaNoWalk() const {
137 return _areaNowalk;
138 }
139
140 const Common::Array<pyrodactyl::level::Stairs> &areaStairs() const {
141 return _areaStairs;
142 }
143};
144} // End of namespace TMX
145
146} // End of namespace Crab
147
148#endif // CRAB_TMXMAP_H
Definition: array.h:52
Definition: list.h:44
Definition: path.h:52
Definition: str.h:59
Definition: PathfindingGrid.h:43
Definition: TMXMap.h:47
Definition: LevelResult.h:44
Definition: Rectangle.h:42
Definition: MusicArea.h:41