diff options
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/main.cpp b/src/main.cpp index 084671a..cc28392 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,8 +11,9 @@ #include <optional> #include "editor.hpp" -#include "floor.hpp" +#include "level.hpp" #include "nfd.hpp" +#include "package.hpp" #include "tileset.hpp" int main() { @@ -22,10 +23,8 @@ int main() { window.setFramerateLimit(60); ImGui::SFML::Init(window); - silly::editor::Tileset tileset; - - silly::editor::TileFloor tileFloor(30, 30); - silly::editor::Editor editor(tileset, tileFloor); + silly::editor::LevelPackage package("test"); + silly::editor::Editor editor(package); sf::Clock deltaClock; while (window.isOpen()) { @@ -42,7 +41,7 @@ int main() { // (cv pasted from // https://www.sfml-dev.org/tutorials/3.0/graphics/view/#showing-more-when-the-window-is-resized) // catch the resize events - if (const auto* resized = event->getIf<sf::Event::Resized>()) { + if (const auto *resized = event->getIf<sf::Event::Resized>()) { // update the view to the new size of the window sf::FloatRect visibleArea({0.f, 0.f}, sf::Vector2f(resized->size)); sf::View view(visibleArea); @@ -62,17 +61,21 @@ int main() { window.clear(); - tileFloor.render(window); - - // rendering grid - for (int x = 0; x < tileFloor.get_width(); x++) { - for (int y = 0; y < tileFloor.get_height(); y++) { - sf::RectangleShape shape({size, size}); - shape.setFillColor(sf::Color::Transparent); - shape.setOutlineColor(sf::Color(80, 80, 80)); - shape.setOutlineThickness(1.0f); - shape.setPosition({x * size, y * size}); - window.draw(shape); + if (!package.get_levels().empty()) { + silly::editor::TileLevel &level = package.get_current_level(); + silly::editor::TileFloor &floor = level.get_current_floor(); + floor.render(window); + + // rendering grid + for (int x = 0; x < floor.get_width(); x++) { + for (int y = 0; y < floor.get_height(); y++) { + sf::RectangleShape shape({size, size}); + shape.setFillColor(sf::Color::Transparent); + shape.setOutlineColor(sf::Color(80, 80, 80)); + shape.setOutlineThickness(1.0f); + shape.setPosition({x * size, y * size}); + window.draw(shape); + } } } |
