-
Notifications
You must be signed in to change notification settings - Fork 0
/
explosion.cpp
73 lines (54 loc) · 1.84 KB
/
explosion.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
#include <iostream>
#include <Windows.h>
#include <chrono>
#include "figura.h"
#include "explosion.h"
#include "symbol.h"
using namespace std;
int Explosion::getType()
{
return 1;
}
void Explosion::run(int console_height)
{
for (int i = 0, j = current_raduis - 1; i <= current_raduis - 1; i++, j--){
if (symbol.coord_y + i < console_height) {
symbol.gotoXY(symbol.coord_x + j, symbol.coord_y + i);
cout << " ";
symbol.gotoXY(symbol.coord_x - j, symbol.coord_y + i);
cout << " ";
}
}
for (int i = 1, j = current_raduis - 2; i <= current_raduis; i++, j--){
if (symbol.coord_y - i < console_height) {
symbol.gotoXY(symbol.coord_x + j, symbol.coord_y - i);
cout << " ";
symbol.gotoXY(symbol.coord_x - j, symbol.coord_y - i);
cout << " ";
}
}
if (current_raduis <= radius) {
for (int i = 0, j = current_raduis; i <= current_raduis; i++, j--){
if (symbol.coord_y + i < console_height) {
symbol.gotoXY(symbol.coord_x + j, symbol.coord_y + i);
symbol.setColor(rand() % 15+1, 0);
cout << (char)((rand() % 63) + 33);
symbol.gotoXY(symbol.coord_x - j, symbol.coord_y + i);
symbol.setColor(rand() % 15+1, 0);
cout << (char)((rand() % 63) + 33);
}
}
for (int i = 1, j = current_raduis - 1; i <= current_raduis; i++, j--){
if (symbol.coord_y - i > -1 && symbol.coord_y - i < console_height) {
symbol.gotoXY(symbol.coord_x + j, symbol.coord_y - i);
symbol.setColor(rand() % 15+1, 0);
cout << (char)((rand() % 63) + 33);
symbol.gotoXY(symbol.coord_x - j, symbol.coord_y - i);
symbol.setColor(rand() % 15+1, 0);
cout << (char)((rand() % 63) + 33);
}
}
}
current_raduis++;
time = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count() + 500;
}