Separate drawing out to view.cpp
This commit is contained in:
parent
dbb69dd80e
commit
b9470696f6
21
main.cpp
21
main.cpp
@ -1,26 +1,13 @@
|
|||||||
#include <SFML/Graphics.hpp>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "view.h"
|
||||||
|
|
||||||
int main()
|
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");
|
printf("Hello meme!\n");
|
||||||
|
|
||||||
while (window.isOpen()) {
|
view_init();
|
||||||
sf::Event event;
|
while (view_update());
|
||||||
while (window.pollEvent(event)) {
|
|
||||||
if (event.type == sf::Event::Closed)
|
|
||||||
window.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
window.clear();
|
|
||||||
window.draw(shape);
|
|
||||||
window.display();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
32
view.cpp
Normal file
32
view.cpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include <SFML/Graphics.hpp>
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user