diff options
| author | ilotterytea <iltsu@alright.party> | 2025-02-01 15:24:04 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-02-01 15:24:04 +0500 |
| commit | 60583043074f01992f2c5b19ec9faf5fb0f69572 (patch) | |
| tree | f276c88e509ef8c57cae188cb72859d495274121 | |
| parent | 3dc3dfc1e4836e45022dd882b645664b1a2ceb4a (diff) | |
feat: render grid
| -rw-r--r-- | src/main.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index e58fc06..0ac1b21 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,8 +1,11 @@ #include <imgui-SFML.h> #include <imgui.h> +#include <SFML/Graphics/Color.hpp> +#include <SFML/Graphics/RectangleShape.hpp> #include <SFML/Graphics/RenderWindow.hpp> #include <SFML/System/Clock.hpp> +#include <SFML/System/Vector2.hpp> #include <SFML/Window/Event.hpp> #include <SFML/Window/VideoMode.hpp> #include <optional> @@ -18,6 +21,9 @@ int main() { sf::Clock deltaClock; while (window.isOpen()) { + // zoom size + float size = 16.0f; + while (const std::optional<sf::Event> event = window.pollEvent()) { if (event.has_value()) { sf::Event e = event.value(); @@ -33,6 +39,18 @@ int main() { window.clear(); + // 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); + } + } + ImGui::SFML::Render(window); window.display(); } |
