-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProjectTemplate.cpp
More file actions
43 lines (31 loc) · 874 Bytes
/
Copy pathProjectTemplate.cpp
File metadata and controls
43 lines (31 loc) · 874 Bytes
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
#include <iostream>
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(50.f);
shape.setFillColor(sf::Color::Green);
sf::RectangleShape rectangle(sf::Vector2f(10, 30));
shape.setOrigin(50, 50);
shape.setPosition(window.getSize().x / 2, window.getSize().y / 2);
float x = window.getSize().x / 2;
float y = 0;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear(sf::Color::Blue);
window.draw(shape);
window.draw(rectangle);
window.display();
y += 1;
if (y > window.getSize().y)
y = 0;
shape.setPosition(x, y);
}
return 0;
}