This repository has been archived by the owner on Mar 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Engine.cpp
93 lines (69 loc) · 1.79 KB
/
Engine.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "Engine.h"
#include "Path.h"
#include <Windows.h>
#include <iostream>
Engine* Engine::instance = 0;
string Engine::playerOne = "";
string Engine::playerTwo = "";
int Engine::framesOne = 16;
int Engine::framesTwo = 16;
DifficultyLevel Engine::difficultyLevel = DifficultyLevel::EASY;
Engine::Engine()
{
this->display = al_create_display(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
if (!display) {
fprintf(stderr, "Failed to create display!\n");
exit(0);
}
al_set_new_display_flags(ALLEGRO_FULLSCREEN | ALLEGRO_MAXIMIZED);
al_set_window_title(this->display, "Game");
this->event_queue = al_create_event_queue();
al_register_event_source(this->event_queue, al_get_keyboard_event_source());
al_register_event_source(this->event_queue, al_get_mouse_event_source());
this->FPS[0] = 30;
this->FPS[1] = 15;
this->FPS[2] = 70;
this->FPS[3] = 1;
this->FPS[4] = 2;
this->FPS[5] = 3;
for (int i = 0; i < 6; i++) {
ALLEGRO_TIMER* timmer = al_create_timer(1.0 / this->FPS[i]);
timmerVector.push_back(timmer);
al_register_event_source(this->event_queue, al_get_timer_event_source(timmer));
}
Path path;
playerOne = path.PLAYER;
playerTwo = path.PLAYER;
startTimers();
}
Engine::~Engine()
{
for (int i = 0; i < 6; i++) {
al_destroy_timer(timmerVector[i]);
}
al_destroy_event_queue(this->event_queue);
al_destroy_display(this->display);
cout << "DESTTTTTTRUKTOR Z EEEEENGINEEEE !!!" << endl;
}
Engine* Engine::getInstance()
{
if (instance == 0)
{
instance = new Engine();
}
return instance;
}
ALLEGRO_DISPLAY* Engine::returnDisplay()
{
return display;
}
void Engine::startTimers()
{
for (int i = 0; i < 6; i++)
al_start_timer(this->timmerVector[i]);
}
void Engine::stopTimers()
{
for (int i = 0; i < 6; i++)
al_stop_timer(this->timmerVector[i]);
}