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;
14class Map
15{
16public:
23 Map(const char* path);
24 void generateTiles();
25private:
26 // struct required for initialisation
27 struct MapData {
28 const std::vector<tmx::Tileset>* tileSets;
29 const std::vector<tmx::Layer::Ptr>* mapLayers;
30 const tmx::Vector2u* mapSize;
31 const tmx::Vector2u* mapTileSize;
32 const std::vector<std::string>* texturePaths;
33 };
34
35 struct TileSetData {
36 std::string texturePath{};
37 tmx::Vector2f textureSize;
38 uint32_t tileCount{};
39 tmx::Vector2u tileCount2D;
40 uint32_t firstGID{};
41 };
42
43 tmx::Map map;
44 Map::MapData mapData;
45 std::vector<std::function<void()>> tileConstructors;
46
47 void loadTileLayer(const tmx::TileLayer& layer);
48 static void addTile(float x, float y, const tmx::Vector2u& mapTileSize, int u, int v, int zIndex, std::string texturePath, bool hasCollision);
49
50 template<typename T>
51 static std::optional<T> getLayerProperty(const std::vector<tmx::Property>& properties, std::string propertyName) { return std::nullopt; };
52};
Definition GameInternal.h:31
void generateTiles()
Generates the map based on the loaded definition.
Definition Map.cpp:180
Map(const char *path)
Loads a .tmx map.
Definition Map.cpp:55