ScummVM API documentation
TMXLayer.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_TMXLAYER_H
32 #define CRAB_TMXLAYER_H
33 
34 #include "crab/Rectangle.h"
35 #include "crab/image/Image.h"
36 #include "crab/TMX/TileInfo.h"
37 
38 #include "common/list.h"
39 
40 namespace Crab {
41 
42 namespace TMX {
43 enum LayerType {
44  // Run of the mill layer full of tiles
45  LAYER_NORMAL,
46 
47  // Layer containing a simple image instead of tiles
48  LAYER_IMAGE,
49 
50  // We do not draw prop layers along with the non-prop layers,
51  // because their draw order depends on the positions of the sprites
52  LAYER_PROP,
53 
54  // Parallax layers are drawn differently, but are still composed of tiles
55  LAYER_PARALLAX,
56 
57  // Auto-hide layers are primarily used for interiors
58  // These are only visible if the player is colliding with them
59  LAYER_AUTOHIDE,
60 
61  // Auto-show layers are the reverse of auto-hide layers
62  // These are only visible if the player is not colliding with them
63  LAYER_AUTOSHOW
64 };
65 
66 class Layer {
67 public:
68  // Name of the layer
69  Common::String _name;
70 
71  // Dimensions of the layer in terms of tiles
72  int _w, _h;
73 
74  Layer() {
75  _w = 0;
76  _h = 0;
77  }
78  bool load(rapidxml::xml_node<char> *node);
79 };
80 
81 // Currently we just use one general purpose layer object instead of multiple inherited classes and stuff
82 class MapLayer : public Layer {
83 public:
84  // The tiles in the layer
86 
87  // The type of layer
88  LayerType _type;
89 
90  // The image in the layer
92 
93  // The coordinates to draw the prop in(x,y) and dimensions of the area(w,h) in terms of tiles
94  // This is also the collision rectangle of the prop and auto hide layer
95  Rect _pos;
96 
97  Common::List<Rect> _boundRect;
98 
99  // The rate of scrolling of image, used for parallax
100  Vector2f _rate;
101 
102  // Is the player colliding with the layer? (used for auto hide layer)
103  bool _collide;
104 
105  MapLayer() : _rate(1, 1) {
106  _type = LAYER_NORMAL;
107  _collide = false;
108  }
109  bool load(const Common::Path &path, rapidxml::xml_node<char> *node);
110 };
111 } // End of namespace TMX
112 
113 } // End of namespace Crab
114 
115 #endif // CRAB_TMXLAYER_H
Definition: str.h:59
Definition: Rectangle.h:42
Definition: array.h:52
Definition: list.h:44
Definition: path.h:52
Definition: Image.h:51
Definition: moveeffect.h:37
Definition: TMXLayer.h:66
Definition: TMXLayer.h:82