JNR
laTileset.h
1 /*
2 
3 Jump'n'Run Engine
4 http://www.atanaslaskov.com/jnr/
5 
6 BSD LICENSE
7 Copyright (c) 2007-2013, Atanas Laskov
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 */
29 #ifndef M_TILESET_H
30 #define M_TILESET_H
31 
33 
34 
45 
47 {
48 protected:
49  char _strName[128];
50 
51  // List of elements in the TS
52  //
53  // Implementation NOTE:
54  // Elements are stored in a vectror, and not a map,
55  // because most elements (e.g. tile-elements) are anonymous (retreived by index).
56  //
57  // Dynamic objects should store a pointer to elements
58  // they need, instead of using getElementIndex() in real-time.
59  //
60  std::vector<laElement> _vElemements;
61 
62  // Compulsory elements, containing some common properties of the level
63  laElement* _pLightProperties;
64  laElement* _pFogProperties;
65  laElement* _pBackgroundProperties;
66 
67  //Sky parameters
68  laSky _TilesetSky;
69 
70  //Segmented background
71  unsigned _nSegmentBackgroundCount;
72  unsigned _arSegmentBackground[16 /*M_MAXELEMENT*/];
73 
74  //Litter Pools
75  unsigned _nLitterPoolsCount;
76  laLitterPools* _arLitterPools;
77 
78  //fxParticleSystem _LavaFx;
79 
80  //Animated linear and wave offsets
81  double _dOffset;
82  double _dWaveOffset;
83 
84  void _readTSIncude(laFileParser* pfp);
85 
86 public:
87  laTileset(void);
88  ~laTileset(void);
89 
90  //Control methods
91  void load(char* strFile);
92  void discard();
93 
94  //Animate
95  void animate(laTimer &t);
96  double getAnimatedOffset() { return _dOffset; }
97  double getAnimatedWaveOffset() { return _dWaveOffset; }
98 
99  //Element get
100  //
101  unsigned getElementIndex(char* strName);
102  laElement* getElement(unsigned i);
103 
104  inline laElement* getElement(char* strName) {
105  return getElement(getElementIndex(strName));
106  }
107 
108  unsigned getElementCnt() { return _vElemements.size(); }
109 
110  // Special elements
111  laElement* getLightElement() { return _pLightProperties; }
112  laElement* getFogElement() { return _pFogProperties; }
113  laElement* getBackgroundElement() { return _pBackgroundProperties; }
114 
115  laSky* getSky() { return &_TilesetSky; }
116 
117  //Segmented background get
118  unsigned getSegmentBackgroundCount() { return _nSegmentBackgroundCount; }
119  unsigned getSegmentBackground(unsigned i) { ASSERT(i<_nSegmentBackgroundCount, ""); return _arSegmentBackground[i]; }
120 
121  //Litter Pools get
122  unsigned getLitterPoolsCount() { return _nLitterPoolsCount; }
123  unsigned getLitterPoolsIndex(char*strName);
124  laLitterPools* getLitterPools(unsigned i) { ASSERT(i<_nLitterPoolsCount, ""); return _arLitterPools+i; };
125 };
127 #endif
Base Class for Tileset Elements.
Definition: laElement.h:48
"Litter pools" to be used for populating laLitterBox
Definition: laLitterBox.h:40
Sky Background Effect.
Definition: laSky.h:48
Tileset Class.
Definition: laTileset.h:46
File Parser.
Definition: laFileParser.h:41
Progressive Task.