blob: 0ac1b21510e22552ec917a5760093271555def82 (
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
|
#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>
#include "floor.hpp"
int main() {
sf::RenderWindow window(sf::VideoMode({800, 600}), "sillyeditor");
window.setFramerateLimit(60);
ImGui::SFML::Init(window);
silly::editor::Floor floor(30, 30);
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();
ImGui::SFML::ProcessEvent(window, e);
}
if (event->is<sf::Event::Closed>()) {
window.close();
}
}
ImGui::SFML::Update(window, deltaClock.restart());
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();
}
return 0;
}
|