tmxparser  2.1.0
 All Classes Functions Variables Pages
TmxMapTile.h
1 //-----------------------------------------------------------------------------
2 // TmxMapTile.h
3 //
4 // Copyright (c) 2010-2014, Tamir Atias
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are met:
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 // DISCLAIMED. IN NO EVENT SHALL TAMIR ATIAS BE LIABLE FOR ANY
19 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 //
26 // Author: Tamir Atias
27 //-----------------------------------------------------------------------------
28 #pragma once
29 
30 namespace Tmx
31 {
32  //-------------------------------------------------------------------------
33  // Flags that may be in the first two bits of the gid.
34  //-------------------------------------------------------------------------
35  const unsigned FlippedHorizontallyFlag = 0x80000000;
36  const unsigned FlippedVerticallyFlag = 0x40000000;
37  const unsigned FlippedDiagonallyFlag = 0x20000000;
38 
39  //-------------------------------------------------------------------------
41  //-------------------------------------------------------------------------
42  struct MapTile
43  {
46  : tilesetId(0)
47  , id(0)
48  , flippedHorizontally(false)
49  , flippedVertically(false)
50  , flippedDiagonally(false)
51  {}
52 
55  MapTile(unsigned _gid, int _tilesetFirstGid, unsigned _tilesetId)
56  : tilesetId(_tilesetId)
57  , id(_gid & ~(FlippedHorizontallyFlag | FlippedVerticallyFlag | FlippedDiagonallyFlag))
58  , flippedHorizontally((_gid & FlippedHorizontallyFlag) != 0)
59  , flippedVertically((_gid & FlippedVerticallyFlag) != 0)
60  , flippedDiagonally((_gid & FlippedDiagonallyFlag) != 0)
61  {
62  gid = id;
63  id -= _tilesetFirstGid;
64  }
65 
67  int tilesetId;
68 
70  unsigned id;
71 
73  unsigned gid;
74 
77 
80 
83  };
84 }
unsigned gid
Gid.
Definition: TmxMapTile.h:73
MapTile()
Default constructor.
Definition: TmxMapTile.h:45
int tilesetId
Tileset id.
Definition: TmxMapTile.h:67
bool flippedVertically
True when the tile should be drawn flipped vertically.
Definition: TmxMapTile.h:79
MapTile(unsigned _gid, int _tilesetFirstGid, unsigned _tilesetId)
Will take a gid and read the attributes from the first two bits of it.
Definition: TmxMapTile.h:55
bool flippedDiagonally
True when the tile should be drawn flipped diagonally.
Definition: TmxMapTile.h:82
Struct to store information about a specific tile in the map layer.
Definition: TmxMapTile.h:42
unsigned id
Id.
Definition: TmxMapTile.h:70
bool flippedHorizontally
True when the tile should be drawn flipped horizontally.
Definition: TmxMapTile.h:76