Skip to content

Commit e2a9443

Browse files
committed
udpate license details
update doxy comments add doxy generator file update readme
1 parent d3bb42c commit e2a9443

19 files changed

+2756
-234
lines changed

README.md

+73-114
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
1-
/*********************************************************************
1+
Tiled tmx map loader for SFML 2.0.0
2+
-----------------------------------
3+
24

3-
Matt Marchant 2013 - 2015
4-
SFML Tiled Map Loader - https://github.com/bjorn/tiled/wiki/TMX-Map-Format
5+
/*********************************************************************
56

6-
The zlib license has been used to make this software fully compatible
7-
with SFML. See http://www.sfml-dev.org/license.php
7+
Matt Marchant 2013 - 2016
8+
SFML Tiled Map Loader - https://github.com/bjorn/tiled/wiki/TMX-Map-Format
89

9-
This software is provided 'as-is', without any express or
10-
implied warranty. In no event will the authors be held
11-
liable for any damages arising from the use of this software.
10+
Zlib License:
11+
This software is provided 'as-is', without any express or
12+
implied warranty. In no event will the authors be held
13+
liable for any damages arising from the use of this software.
1214

13-
Permission is granted to anyone to use this software for any purpose,
14-
including commercial applications, and to alter it and redistribute
15-
it freely, subject to the following restrictions:
15+
Permission is granted to anyone to use this software for any purpose,
16+
including commercial applications, and to alter it and redistribute
17+
it freely, subject to the following restrictions:
1618

17-
1. The origin of this software must not be misrepresented;
18-
you must not claim that you wrote the original software.
19-
If you use this software in a product, an acknowledgment
20-
in the product documentation would be appreciated but
21-
is not required.
19+
1. The origin of this software must not be misrepresented;
20+
you must not claim that you wrote the original software.
21+
If you use this software in a product, an acknowledgment
22+
in the product documentation would be appreciated but
23+
is not required.
2224

23-
2. Altered source versions must be plainly marked as such,
24-
and must not be misrepresented as being the original software.
25+
2. Altered source versions must be plainly marked as such,
26+
and must not be misrepresented as being the original software.
2527

26-
3. This notice may not be removed or altered from any
27-
source distribution.
28+
3. This notice may not be removed or altered from any
29+
source distribution.
2830

29-
*********************************************************************/
31+
*********************************************************************/
3032

31-
This class is designed to load TILED .tmx format maps, compatible with
33+
This class is designed to load TILED .tmx format maps, compatible with
3234
TILED up to version 0.9.0
3335

3436
http://trederia.blogspot.co.uk/2013/05/tiled-map-loader-for-sfml.html
@@ -56,13 +58,22 @@ What's not supported / limitations
5658
Parsing of individual tile properties
5759
Staggered isometric maps
5860

61+
62+
Requirements
63+
------------
64+
65+
pugixml (included)
66+
zlib (http://zlib.net/)
67+
SFML 2.x (http://sfml-dev.org)
68+
Minimal C++11 compiler support (tested with VS11 and GCC4.7)
69+
70+
5971
Usage
6072
-----
6173

62-
First download the zlib library which matches your compiler and link it to your
63-
project, then add the map loader .cpp files to your project/command line. Only
64-
add the tmx2box2d files if you are using box2D for physics and wish to convert
65-
map object data to box2D physics bodies.
74+
With the Cmake file provided create a project for the compiler of your choice to build and
75+
install the map loader as either a static or shared library. You can use cmake-gui (useful
76+
for windows users) to see all the options, such as building the example applications.
6677

6778

6879
To quickly get up and running create an instance of the MapLoader class
@@ -71,25 +82,25 @@ To quickly get up and running create an instance of the MapLoader class
7182

7283
load a map file
7384

74-
ml.Load("map.tmx");
85+
ml.load("map.tmx");
7586

7687
and draw it in your main loop
7788

7889
renderTarget.draw(ml);
7990

8091

8192
Note that the constructor takes a path to the directory containing the map files as a parameter (with
82-
or without the trailing '/') so that you only need pass the map name to MapLoader::Load().If you have
93+
or without the trailing '/') so that you only need pass the map name to `MapLoader::load()`. If you have
8394
images and/or tileset data in another directory you may add it with:
8495

85-
ml.AddSearchPath(path);
96+
ml.addSearchPath(path);
8697

8798
*before* attempting to load the map file.
8899

89100
New maps can be loaded simply by calling the load function again, existing maps will be automatically
90-
unloaded. MapLoader::Load() also returns true on success and false on failure, to aid running the function
101+
unloaded. `MapLoader::load()` also returns true on success and false on failure, to aid running the function
91102
in its own thread for example. Conversion functions are provided for converting coordinate spaces between
92-
orthogonal and isometric. For instance MapLoader::OrthogonalToIsometric will convert mouse coordinates from
103+
orthogonal and isometric. For instance `MapLoader::orthogonalToIsometric()` will convert mouse coordinates from
93104
screen space:
94105

95106
0--------X
@@ -100,7 +111,7 @@ screen space:
100111
|
101112
Y
102113

103-
to Isometric space:
114+
to isometric space:
104115

105116
0
106117
/ \
@@ -109,16 +120,17 @@ to Isometric space:
109120
/ \
110121
Y X
111122

112-
Layer information can be accessed through MapLoader::GetLayers()
123+
Layer information can be accessed through `MapLoader::getLayers()`
113124

114125
bool collision;
115-
for(auto layer = ml.GetLayers().begin(); layer != ml.GetLayers().end(); ++layer)
126+
const auto& layers = ml.getLayers();
127+
for(const auto& layer : layers)
116128
{
117-
if(layer->name == "Collision")
129+
if(layer.name == "Collision")
118130
{
119-
for(auto object = layer->objects.begin(); object != layer->objects.end(); ++object)
131+
for(const auto& object : layer.objects)
120132
{
121-
collision = object->Contains(point);
133+
collision = object.contains(point);
122134
}
123135
}
124136
}
@@ -128,34 +140,39 @@ The quad tree is used to reduce the number of MapObjects used during a query. If
128140
hundreds of objects which are used for collision it makes little sense to test them all if only
129141
a few are ever within collision range. For example in your update loop first call:
130142

131-
ml.UpdateQuadTree(myRect);
143+
ml.updateQuadTree(myRect);
132144

133-
where myRect is the area representing the root node. You will probably only want to start with
134-
MapObjects which are visible on screen, so set myRect to your view area. Then query the quad tree
135-
with another floatRect, representing the area for potential collision. This could be the bounding
145+
where `myRect` is the area representing the root node. You will probably only want to start with
146+
MapObjects which are visible on screen, so set `myRect` to your view area. Then query the quad tree
147+
with another FloatRect representing the area for potential collision. This could be the bounding
136148
box of your sprite:
137149

138-
std::vector<MapObject*> objects = ml.QueryQuadTree(mySprite.getGlobalBounds());
150+
std::vector<MapObject*> objects = ml.queryQuadTree(mySprite.getGlobalBounds());
139151

140152
This returns a vector of pointers to MapObjects contained within any quads which are intersected
141153
by your sprite's bounds. You can then proceed to perform any collision testing as usual.
142154

143155

144-
Some utility functions are providied in tmx2box2d.h/cpp. If you use box2D for physics then add these
145-
files to you project and then create box2D physics bodies using:
156+
Some utility functions are providied in tmx2box2d.h/cpp. If you use box2d for physics then add these
157+
files to you project, or set the box2d option to true when configuring the cmake file. You may then
158+
create box2d physics bodies using the BodyCreator:
146159

147-
b2Body* body = tmx::BodyCreator::Add(mapObject, b2World);
160+
tmx::BodyCreator bodyCreator;
161+
b2Body* body = bodyCreator.add(mapObject, b2World);
148162

149-
where b2World is a reference to a valid box2D physics world. As box2D uses a different coordinate
150-
system to SFML there are 4 functions for converting from one space to another:
163+
where b2World is a reference to a valid box2D physics world. The body creator is only a utility
164+
class, so it is no problem letting it go out of scope once your bodies are all created. As box2d
165+
uses a different coordinate system to SFML there are 4 functions for converting from one space to
166+
another:
151167

152-
b2Vec2 SfToBoxVec(const sf::Vector2f& vec);
153-
sf::Vector2f BoxToSfVec(const b2Vec2& vec);
154-
float SfToBoxFloat(float val);
155-
float BoxToSfFloat(float val);
168+
b2Vec2 sfToBoxVec(const sf::Vector2f& vec);
169+
sf::Vector2f boxToSfVec(const b2Vec2& vec);
170+
float sfToBoxFloat(float val);
171+
float boxToSfFloat(float val);
156172

157173
You should use these whenever you are trying to draw with SFML based on the physics output, or set
158-
box2D parameters in SFML world values.
174+
box2d parameters in SFML world values. When using box2d you may find that the build types of both
175+
the map loader and box2d should match (ie both static or both shared libs).
159176

160177

161178
Debugging output can be enabled with one of the following preprocessor directives:
@@ -172,76 +189,18 @@ all output is written to a file named output.log in the executable directory
172189

173190
log output is directed to both the console and output.log
174191

175-
Logging is diabled by default. The level of log information can be set with
192+
Logging is disabled by default. The level of log information can be set with
176193

177-
Logger::SetLogLevel()
194+
tmx::setLogLevel()
178195

179196
by providing a bitmask for the level required. For instance to only log warnings
180197
and errors use:
181198

182-
Logger::SetLogLevel(Logger::Warning | Logger::Error);
199+
tmx::setLogLevel(tmx::Logger::Warning | tmx::Logger::Error);
183200

184201

185202

186203
For more detailed examples see the source in the examples folder, and the wiki on github:
187204
https://github.com/fallahn/sfml-tmxloader/wiki
188205

189-
190-
191-
Requirements
192-
------------
193-
194-
pugixml (included)
195-
zlib (http://zlib.net/)
196-
SFML 2.x (http://sfml-dev.org)
197-
Minimal C++11 compiler support (tested with VS11 and GCC4.7)
198-
199-
200-
Note about CMake file
201-
---------------------
202-
203-
The tmx map loader was designed to have its source included as part of another project. The
204-
CMake file is included for linux / mac platforms where building installing libraries is the
205-
norm. The tmx source doesn't explicitly export any functions, so when building the tmx files
206-
as a library under Windows (particularly Visual Studio) VC will not generate any lib files.
207-
To work around this just include the tmx source files in your Visual Studio project (as well
208-
as pugixml), so that they are compiled as part of the final executable.
209-
210-
211-
Revision History
212-
----------------
213-
214-
300513 0.1 Initial Release
215-
216-
140613 0.1a Bug fix compiling with MinGW/GCC
217-
218-
240613 0.2 Added: Quadtree support for partitioning of MapObjects, Getter for map size property
219-
220-
030713 0.3 Added: rendering of map via vertex array. Old style rendering is still available with Draw2()
221-
222-
190713 0.4 Updated: MapObject::SetPosition and MapObject::Move now update object's debug and AABB properties.
223-
Added: Map layers can be drawn by type (front, back, all or debug) and by index.
224-
Removed: debug param from draw function - debug info is now drawn separately
225-
Updated: minimum version of visual studio required is now VS11
226-
227-
060813 0.5 Updated: tileset images are cached and reused when the same tileset is used more than once
228-
229-
280813 0.6 Updated: optimised draw calls by checking if a tileset vertex array is actually visible before
230-
drawing
231-
Fixed: Textures not properly being flushed when loading new maps causing tile sets to be incorrectly
232-
displayed
233-
Added: MapLayer RenderStates property and setter for shader
234-
235-
041013 0.7 Added: Getters for object first / last points
236-
Removed: old Draw2 function
237-
Updated: constness of some function parameters
238-
Updated: inherited load class from sf::Drawable and sf::NonCopyable
239-
Updated: removed tile caching in favour of drawing objects via sprites with subrects for significantly
240-
improved loading times - particularly with large or multiple tile sets
241-
242-
291013 0.8 Updated: Refactored object class and cleaned up interface
243-
Added: utility functions to MapObject class for collision calculations
244-
245-
131113 0.9 Fixed: MapObject::Intersects failed due to const correctness
246-
Rehosted project on GitHub
247-
206+
Doxygen documentation can also be generated with the doxy file in the docs folder.

0 commit comments

Comments
 (0)