-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathline.cpp
92 lines (74 loc) · 1.84 KB
/
line.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
#include <iostream>
#include <Windows.h>
#include <chrono>
#include "figura.h"
#include "symbol.h"
#include "line.h"
using namespace std;
int Line::getType()
{
return 0;
}
void Line::run(int console_height)
{
if (symbols_in_line.size() < lenght && symbol.coord_y < lenght - 1) {
startRun();
}
else if (symbol.coord_y >= console_height - 1 && !symbols_in_line.empty()) {
endRun();
}
else if (!symbols_in_line.empty()) {
middleRun();
}
for (int i = 0; i < symbols_in_line.size(); i++){
symbol.gotoXY(symbols_in_line[i].coord_x, symbols_in_line[i].coord_y);
symbol.setColor(symbols_in_line[i].color, 0);
cout << symbols_in_line[i].sign;
}
time = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count() + interval;
}
void Line::startRun()
{
symbol.sign = ((char)((rand() % 63) + 33));
if (epilepsy_flag)
{
symbol.color = rand() % 15;
}
else
{
symbol.color = 10;
}
symbol.coord_y++;
symbols_in_line.insert(symbols_in_line.begin(), symbol);
}
void Line::endRun()
{
symbol.gotoXY(symbol.coord_x, symbols_in_line[symbols_in_line.size() - 1].coord_y);
cout << " ";
symbols_in_line.pop_back();
}
void Line::middleRun()
{
symbol.sign = ((char)((rand() % 63) + 33));
if (epilepsy_flag) {
symbol.color = rand() % 15;
}
else {
symbol.color = 10;
}
symbol.gotoXY(symbol.coord_x, symbols_in_line[symbols_in_line.size() - 1].coord_y);
cout << " ";
symbols_in_line.pop_back();
symbol.coord_y++;
symbols_in_line.insert(symbols_in_line.begin(), symbol);
}
void Line::trim()
{
if (!symbols_in_line.empty()) {
symbol.gotoXY(symbols_in_line[0].coord_x, symbols_in_line[0].coord_y);
cout << " ";
lenght--;
symbols_in_line.erase(symbols_in_line.begin());
symbol.coord_y--;
}
}