R-Type  1.0.1.0
Rewrite of the R-Type game with networking ability
Loading...
Searching...
No Matches
Map.hpp
1/*
2** EPITECH PROJECT, 2023
3** Map.hpp
4** File description:
5** Map.hpp
6*/
7
8#ifndef PARSER_MAP_HPP
9#define PARSER_MAP_HPP
10
11#include "uranus/engine/Engine.hpp"
12#include <nlohmann/json.hpp>
13#include <SFML/Graphics.hpp>
14#include <SFML/Window.hpp>
15#include <uranus/external/tileson/Tileson.hpp>
16
17class Tile {
18public:
19 explicit Tile(const std::string &name, sf::VertexArray &quad);
20
21 inline const std::string &getName() const { return _name; };
22
23 inline const sf::VertexArray &getQuad() const { return _quad; };
24
25private:
26 std::string _name;
27 sf::VertexArray _quad;
28};
29
30class Layer {
31public:
32 explicit Layer(const std::string &name);
33
34 inline const std::string &getName() const { return _name; };
35
36 inline std::vector<Tile> &getTiles() { return _tiles; };
37
38 inline const std::vector<Tile> &getTiles() const { return this->_tiles; };
39
40private:
41 std::string _name;
42 std::vector<Tile> _tiles;
43};
44
45class Map : public sf::Drawable,
46 public sf::Transformable {
47public:
48 explicit Map(const std::string &path, std::shared_ptr<engine::TextureManager> &textureMng);
49
50 void loadMap();
51 void loadTiles(tson::Layer *layer);
52 void loadTexture(std::shared_ptr<engine::TextureManager> &textureMng);
53 tson::Tileset *getTilesetByTileId(uint32_t id);
54 static sf::Vector2i getTilePosition(uint32_t id, tson::Tileset *tileset);
55
56private:
57 void draw(sf::RenderTarget &target, sf::RenderStates states) const override;
58
59 std::unique_ptr<tson::Map> _map;
60 std::vector<Layer> _layers;
61 std::map<std::string, std::shared_ptr<sf::Texture>> _textures;
62};
63
64#endif // PARSER_MAP_HPP
Definition: Map.hpp:30
Definition: Map.hpp:46
Definition: Map.hpp:17
Definition: Tileson.hpp:4282
Definition: Tileson.hpp:6314