diff --git a/main.cpp b/main.cpp index dff85e8..69c2479 100644 --- a/main.cpp +++ b/main.cpp @@ -1,26 +1,13 @@ -#include #include +#include "view.h" + int main() { - sf::Uint32 style = sf::Style::Titlebar; - sf::RenderWindow window(sf::VideoMode(1600, 900), "SFML works!", style); - sf::CircleShape shape(450.f); - shape.setFillColor(sf::Color::Green); - printf("Hello meme!\n"); - while (window.isOpen()) { - sf::Event event; - while (window.pollEvent(event)) { - if (event.type == sf::Event::Closed) - window.close(); - } - - window.clear(); - window.draw(shape); - window.display(); - } + view_init(); + while (view_update()); return 0; } diff --git a/view.cpp b/view.cpp new file mode 100644 index 0000000..b477482 --- /dev/null +++ b/view.cpp @@ -0,0 +1,32 @@ +#include +#include "view.h" + +static sf::Uint32 style = sf::Style::Titlebar; +static sf::RenderWindow window(sf::VideoMode(1600, 900), "SFML works!", style); +static sf::CircleShape shape(450.f); + +int view_init() +{ + shape.setFillColor(sf::Color::Green); + return 1; +} + +int view_update() +{ + if (!window.isOpen()) return 0; + + sf::Event event; + while (window.pollEvent(event)) { + if (event.type == sf::Event::Closed) { + window.close(); + return 0; + } + } + + window.clear(); + window.draw(shape); + window.display(); + + return 1; +} + diff --git a/view.h b/view.h new file mode 100644 index 0000000..2e3c2f1 --- /dev/null +++ b/view.h @@ -0,0 +1,7 @@ +#ifndef VIEW_H +#define VIEW_H + +int view_init(); +int view_update(); + +#endif