-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (33 loc) · 1.01 KB
/
main.cpp
File metadata and controls
48 lines (33 loc) · 1.01 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
#include "includes.h"
#include "world.h"
#include "texturemanager.h"
World g_world;
RenderWindow g_window(sf::VideoMode(800, 600), "SFML window");
Font g_font;
int main(){
// Create the main window
sf::View view(sf::FloatRect(0, 0, 1000, 600));
g_font.loadFromFile("gfx/Gargi.ttf");
// Start the game loop
while (g_window.isOpen() && !sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
{
// Process events
sf::Event event;
while (g_window.pollEvent(event))
{
// Close window: exit
if (event.type == sf::Event::Closed)
g_window.close();
}
// Clear screen
g_window.clear();
sf::sleep(sf::milliseconds(15));
view.reset(sf::FloatRect(g_world.getPlayer()->getPos().x-400, g_world.getPlayer()->getPos().y-300, 800, 600));
g_world.frame();
g_world.draw();
g_window.setView(view);
// Update the window
g_window.display();
}
return EXIT_SUCCESS;
}