From 0ae2d10bdfd3d4fe7483829fb9c9257973e644c7 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sun, 2 Feb 2025 02:13:52 +0500 Subject: feat: level package --- src/level.hpp | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/level.hpp (limited to 'src/level.hpp') diff --git a/src/level.hpp b/src/level.hpp new file mode 100644 index 0000000..2364413 --- /dev/null +++ b/src/level.hpp @@ -0,0 +1,67 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include "tileset.hpp" + +namespace silly::editor { + struct Tile { + std::shared_ptr tile; + sf::Vector2i position; + float rotation; + }; + + struct TileLayer { + std::vector 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 &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 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 std::vector &get_floors() const; + + const std::string &get_name() const; + + private: + const std::string name; + + int current_floor; + std::vector floors; + }; +} \ No newline at end of file -- cgit v1.2.3