-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
56 lines (44 loc) · 1.13 KB
/
Copy pathmain.cpp
File metadata and controls
56 lines (44 loc) · 1.13 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
56
#include <iostream>
#include <SFML/Graphics.hpp>
#include "GameManager.h"
#include <stdlib.h>
#include <time.h>
int main()
{
srand(time(NULL));
// Create the main window
sf::RenderWindow app(sf::VideoMode(800, 600), "Space Game");
GameManager gameManager(app);
if (!gameManager.Initialize())
{
std::cout << "Failure loading graphics." << std::endl;
return EXIT_FAILURE;
}
// Clock used to calculate the delta time
sf::Clock deltaClock;
// Start the game loop
while (app.IsOpened())
{
// Process events
sf::Event event;
while (app.GetEvent(event))
{
// Close window : exit
if (event.Type == sf::Event::Closed)
app.Close();
}
float elapsedTime = deltaClock.GetElapsedTime();
if (elapsedTime > 0)
{
gameManager.UpdateGame(elapsedTime);
deltaClock.Reset();
}
// Clear screen
app.Clear();
gameManager.DrawGame();
// Update the window
app.Display();
}
gameManager.FreeResources();
return EXIT_SUCCESS;
}