PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
wld_tilebox.h
1 /*
2  * Platformer Game Engine by Wohlstand, a free platform for game making
3  * Copyright (c) 2015 Vitaly Novichkov <admin@wohlnet.ru>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef WLD_TILEBOX_H
20 #define WLD_TILEBOX_H
21 
22 #include <QVector>
23 #include <unordered_map>
24 #include <common_features/point.h>
25 #include <PGE_File_Formats/wld_filedata.h>
26 #include <graphics/gl_renderer.h>
27 #include <data_configs/config_manager.h>
28 
29 class WorldNode
30 {
31 public:
32  enum nodeType
33  {
34  unknown=0,
35  tile,
36  scenery,
37  path,
38  level,
39  musicbox
40  };
41 
42  WorldNode();
43  virtual ~WorldNode();
44  WorldNode(const WorldNode &xx);
45  virtual void render(float, float) {}
46  virtual bool collidePoint(long rx, long ry);
47  virtual bool collideWith(WorldNode *it);
48  int type;
49  long x;
50  long y;
51  long w;
52  long h;
53  float r;
54  float g;
55  float b;
56  double Z;
57  PGE_Texture texture;
58  bool animated;
59  long animatorID;
60  bool vizible;
61 };
62 
63 class WldTileItem: public WorldNode
64 {
65 public:
66  WldTileItem(WorldTiles _data);
67  WldTileItem(const WldTileItem &x);
68  ~WldTileItem();
69  bool init();
70  void render(float rx, float ry);
71  obj_w_tile setup;
72  WorldTiles data;
73 };
74 
76 {
77 public:
80  ~WldSceneryItem();
81  bool init();
82  void render(float rx, float ry);
83  obj_w_scenery setup;
84  WorldScenery data;
85 };
86 
87 class WldPathItem: public WorldNode
88 {
89 public:
90  WldPathItem(WorldPaths _data);
91  WldPathItem(const WldPathItem &x);
92  ~WldPathItem();
93  bool init();
94  void render(float rx, float ry);
95  obj_w_path setup;
96  WorldPaths data;
97 };
98 
99 class WldLevelItem: public WorldNode
100 {
101 public:
102  WldLevelItem(WorldLevels _data);
103  WldLevelItem(const WldLevelItem &x);
104  ~WldLevelItem();
105  bool init();
106  void render(float rx, float ry);
107 
108  obj_w_level setup;
109  float offset_x;
110  float offset_y;
111  PGE_Texture _path_tex;
112  float _path_offset_x;
113  float _path_offset_y;
114  PGE_Texture _path_big_tex;
115  float _path_big_offset_x;
116  float _path_big_offset_y;
117  WorldLevels data;
118 };
119 
121 {
122 public:
125  ~WldMusicBoxItem();
126  WorldMusic data;
127 };
128 
129 
130 
131 
132 class TileBox
133 {
134 public:
135  TileBox();
136  TileBox(unsigned long size);
137  ~TileBox();
138  void addNode(long X, long Y, long W, long H, WorldNode* item);
139  QVector<WorldNode* > query(long X, long Y, QVector<WorldNode * > &list);
140  QVector<WorldNode* > query(long Left, long Top, long Right, long Bottom, QVector<WorldNode * > &list, bool z_sort=false);
141  PGE_Point applyGrid(long x, long y);
142  void clean();
143 
144  const long &grid();
145  const long &grid_half();
146 private:
147  void sortElements(QVector<WorldNode * > &list);
148  std::unordered_map<long, std::unordered_map<long, QVector<WorldNode* > > > map;
149  long gridSize;
150  long gridSize_h;
151 };
152 
153 
154 #endif // WLD_TILEBOX_H
155 
Definition: wld_tilebox.h:87
Definition: wld_filedata.h:26
Definition: pge_texture.h:32
Definition: obj_wld_items.h:98
Definition: obj_wld_items.h:75
Definition: wld_tilebox.h:75
Definition: wld_tilebox.h:63
Definition: wld_tilebox.h:29
Definition: wld_filedata.h:59
Definition: wld_tilebox.h:132
Definition: point.h:23
Definition: wld_filedata.h:48
Definition: wld_tilebox.h:99
Definition: wld_filedata.h:83
Definition: obj_wld_items.h:26
Definition: wld_filedata.h:37
Definition: obj_wld_items.h:52
Definition: wld_tilebox.h:120