-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
53 lines (42 loc) · 1.04 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
53
#include <SFML/Graphics.hpp>
#include <chrono>
#include "Headers/Grid.hpp"
int main()
{
int windowWidth = 1200;
int windowHeight = 800;
int sideBarWidth = 400;
int titleHeight = 100;
int width = 600;
int height = 600;
int size = 40;
int x = width / size;
int y = height / size;
// Create the main window
sf::RenderWindow window(sf::VideoMode(windowWidth, windowHeight), "Game of Life");
Grid grid(size, sideBarWidth, titleHeight, x, y);
sf::Clock clock;
// Main Loop
while (1 == window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
// Close window
if (event.type == sf::Event::Closed)
{
window.close();
}
}
window.clear(sf::Color::Black);
if (clock.getElapsedTime().asSeconds() > 1.0f)
{
grid.update();
clock.restart();
}
grid.render(window);
// Display Stuff
window.display();
}
return 0;
}