summaryrefslogtreecommitdiff
path: root/src/floor.hpp
blob: 423616657e1d40003370678a71b873fa46a5ea6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once

#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Vector2.hpp>
#include <memory>
#include <vector>

#include "tileset.hpp"

namespace silly::editor {
  struct Tile {
      std::shared_ptr<TilesetTile> tile;
      sf::Vector2i position;
      float rotation;
  };

  struct TileLayer {
      std::vector<Tile> tiles;
      TilesetTileType type;
  };

  class TileFloor {
    public:
      TileFloor(int width, int height) : width(width), height(height) {
        // creating vectors for every tile type
        for (int i = 0; i < 2; i++) {
          this->layers.push_back({{}, (TilesetTileType)i});
        }
      }

      ~TileFloor() = default;

      void render(sf::RenderWindow &window) const;
      void place_tile(std::shared_ptr<TilesetTile> &tile,
                      const sf::Vector2i &position, const float &rotation);
      void remove_tile(TilesetTileType type, const sf::Vector2i &position);

      const int get_width() const;
      const int get_height() const;

    private:
      int width, height;
      int activeLayerIndex;
      std::vector<TileLayer> layers;
  };
}