blob: d6294000d2ac95986150e51d4d8d8a8d4c104ab5 (
plain)
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
57
58
59
60
61
62
63
64
|
#pragma once
#include "interfaces/cell_helper.hpp"
#include "interfaces/cursor.hpp"
#include "interfaces/game.hpp"
#include "interfaces/generation_tracker.hpp"
#include "interfaces/input.hpp"
#include "interfaces/matrix.hpp"
#include "interfaces/scene.hpp"
#include "interfaces/status_manager.hpp"
#include "engine/data/vector2.hpp"
#include <chrono>
#include <cstddef>
#include <list>
#include <memory>
constexpr auto DEFAULT_MIN_TIME_SINCE_LAST_GEN_MILLIS = 200;
constexpr auto MIN_TIME_SINCE_LAST_GEN_INCREMENT = 50;
constexpr auto MIN_TIME_SINCE_LAST_GEN_DECREMENT = 50;
class Game : public IGame
{
public:
Game(
std::shared_ptr<IScene> scene,
std::shared_ptr<ICursorController> cursor_controller,
std::shared_ptr<IGenerationTracker> generation_tracker,
std::shared_ptr<IStatusManager> status_manager,
std::shared_ptr<IUserInputObserver> user_input_observer,
std::shared_ptr<ICellHelper> cell_helper) noexcept;
void on_start() noexcept override;
void on_update() noexcept override;
void on_exit() const noexcept override;
private:
std::shared_ptr<IScene> _scene;
std::shared_ptr<ICursorController> _cursor_controller;
std::shared_ptr<IGenerationTracker> _generation_tracker;
std::shared_ptr<IStatusManager> _status_manager;
std::shared_ptr<IUserInputObserver> _user_input_observer;
std::shared_ptr<ICellHelper> _cell_helper;
using TimePoint = std::chrono::system_clock::time_point;
TimePoint _last_update_time;
TimePoint _last_gen_update_time;
int32_t _min_time_since_last_gen_millis = DEFAULT_MIN_TIME_SINCE_LAST_GEN_MILLIS;
std::list<Vector2> _living_cell_positions;
auto _move_cursor(const Vector2 &direction) noexcept -> bool;
void _set_space(
const std::shared_ptr<IMatrix<IScene::MatrixElement>> &matrix,
const Vector2 &position,
char character) noexcept;
};
|