-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
55 lines (42 loc) · 1.24 KB
/
main.cpp
File metadata and controls
55 lines (42 loc) · 1.24 KB
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
// library
#include <SFML/Graphics.hpp>
// main program
int main()
{
// create window
sf::RenderWindow window(sf::VideoMode({800, 600}), "Title");
// create rectangle
sf::RectangleShape rectangle({400.f, 200.f});
// color & outline
rectangle.setFillColor(sf::Color(255, 213, 128));
rectangle.setOutlineThickness(-20.f);
rectangle.setOutlineColor(sf::Color(255, 170, 0));
// set origin
rectangle.setOrigin({200.f, 100.f});
// transformation
// rectangle.setScale({1.5f, 1.f});
rectangle.setRotation(sf::degrees(30.f));
rectangle.setPosition({400.f, 300.f});
// while window is still open
while (window.isOpen())
{
// handle events
while (std::optional event = window.pollEvent())
{
// when close button is clicked
if (event->is<sf::Event::Closed>())
{
// close window
window.close();
}
}
// fill window with color
window.clear(sf::Color(127, 127, 127));
// draw
window.draw(rectangle);
// display
window.display();
}
// program end successfully
return 0;
}