-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
52 lines (40 loc) · 1.07 KB
/
main.cpp
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
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <unistd.h>
#include <cAudio/cAudio.h>
#include <SFML/Graphics.hpp>
#include "level.hpp"
int main() {
srand(time(nullptr));
// Create the main window
sf::RenderWindow window(sf::VideoMode(WIDTH, HEIGHT), "SFML window", sf::Style::Titlebar | sf::Style::Close);
std::cout << "Loading level" << std::endl;
Level level;
sf::Clock deltaClock;
std::cout << "Starting main loop" << std::endl;
while (window.isOpen())
{
sf::Time dt = deltaClock.restart();
// Process events
sf::Event event;
while (window.pollEvent(event))
{
// Close window: exit
switch (event.type) {
case sf::Event::Closed:
window.close();
break;
default:
break;
}
}
level.update(dt.asSeconds());
// Clear screen
window.clear();
level.draw(&window);
// Update the window
window.display();
}
return EXIT_SUCCESS;
}