VEGO-Engine  0.1
Loading...
Searching...
No Matches
Map.h
1#pragma once
2
3#include <functional>
4#include <optional>
5#include <string>
6#include <vector>
7
8#include <tmxlite/Map.hpp>
9#include <tmxlite/Property.hpp>
10#include <tmxlite/TileLayer.hpp>
11#include <tmxlite/Types.hpp>
12
13class GameInternal;
15class Map
16{
17public:
24 Map(const char* path);
26 void generateTiles();
27private:
28 // struct required for initialisation
29 struct MapData {
30 const std::vector<tmx::Tileset>* tileSets;
31 const std::vector<tmx::Layer::Ptr>* mapLayers;
32 const tmx::Vector2u* mapSize;
33 const tmx::Vector2u* mapTileSize;
34 const std::vector<std::string>* texturePaths;
35 };
36
37 struct TileSetData {
38 std::string texturePath{};
39 tmx::Vector2f textureSize;
40 uint32_t tileCount{};
41 tmx::Vector2u tileCount2D;
42 uint32_t firstGID{};
43 };
44
45 tmx::Map map;
46 Map::MapData mapData;
47 std::vector<std::function<void()>> tileConstructors;
48
49 void loadTileLayer(const tmx::TileLayer& layer);
50 static void addTile(float x, float y, const tmx::Vector2u& mapTileSize, int u, int v, int zIndex, std::string texturePath, bool collision);
51
52 template<typename T>
53 static std::optional<T> getLayerProperty(const std::vector<tmx::Property>& properties, std::string propertyName) { return std::nullopt; };
54};
void generateTiles()
Used to generate the tiles of a previously loaded map.
Definition Map.cpp:180
Map(const char *path)
Loads a .tmx map.
Definition Map.cpp:55