blob: 59ebc3ccc849da565df642f1589a6f4485afa84c (
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#pragma once
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Vector2.hpp>
#include <memory>
#include <string>
#include <vector>
#include "sets/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(const 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;
const int get_tile_count() const;
const std::vector<TileLayer> &get_layers() const;
std::string export_to_string() const;
private:
int width, height;
int activeLayerIndex = 0;
std::vector<TileLayer> layers;
};
class TileLevel {
public:
TileLevel(const std::string &name) : name(name) {}
~TileLevel() = default;
void add_floor(TileFloor floor);
void move_to_floor(int floor_id);
TileFloor &get_current_floor();
const int &get_current_floor_index() const;
const std::vector<TileFloor> &get_floors() const;
const std::string &get_name() const;
std::string export_to_string() const;
private:
const std::string name;
int current_floor = 0;
std::vector<TileFloor> floors;
};
}
|