-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
54 lines (43 loc) · 1.24 KB
/
Copy pathmain.cpp
File metadata and controls
54 lines (43 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
#include <iostream>
#include <SFML//Graphics.hpp>
#include "Button.h"
#include "Field.h"
#include "TextInput.h"
#include "UI.h"
int main() {
Field field;
Object object;
object.setPosition(Vector2f(0,0));
object.setVelocity(Vector2f(10,10));
field.AddObject(std::make_shared<Object>(object));
UI ui;
ui.SetDefaultPreset(&field);
sf::RenderWindow window(sf::VideoMode(1360, 720), "15");
window.setFramerateLimit(60);
sf::Event event{};
Clock clock;
while (window.isOpen())
{
float time = clock.getElapsedTime().asMilliseconds();
time /= 100;
clock.restart();
window.clear();
field.Update(time);
field.Draw(window);
ui.Draw(window);
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed) window.close();
if (event.type == sf::Event::KeyPressed)
{
if (event.key.code == sf::Keyboard::Escape) window.close();
if (event.key.code == sf::Keyboard::Q) field = Field();
}
MyEvent myEvent(event);
ui.HandleEvent(myEvent);
field.HandleEvent(myEvent);
}
window.display();
}
return 0;
}