-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLife.h
47 lines (34 loc) · 858 Bytes
/
Life.h
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
#pragma once
#include <SFML/Graphics.hpp>
#include <vector>
#include <memory>
#include "BlocksGrid.h"
constexpr int WIDTH = 1800;
constexpr int HEIGHT = 800;
constexpr int BLOCK_SIZE = 10;
constexpr int DEFAULT_SPEED = 50;
constexpr int XBLOCKS = WIDTH/BLOCK_SIZE;
constexpr int YBLOCKS = HEIGHT/BLOCK_SIZE;
class Life {
private:
std::shared_ptr<sf::RenderWindow> window;
sf::VideoMode videoMode;
sf::Event ev;
bool isWindowFocused;
void initVariables();
void initWindow();
void initEnviroment();
std::unique_ptr<BlocksGrid> blocksGrid;
void scanBlocks();
int scanNeighbourBlocks(sf::Vector2f indexes);
bool playEnabled;
int speed;
sf::Clock clock;
public:
Life();
virtual ~Life();
const bool running() const;
void pollEvents();
void update();
void render();
};