blob: dcb9fa7f9e2fd99af53580eabe85d2f926bd8502 (
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(const sf::Vector2i &position);
const int get_width() const;
const int get_height() const;
private:
int width, height;
int activeLayerIndex;
std::vector<TileLayer> layers;
};
}
|