-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCANIMAL.cpp
165 lines (159 loc) · 2.92 KB
/
CANIMAL.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#include "CANIMAL.h"
void CANIMAL::SetColor(WORD color)
{
HANDLE hConsoleOutput;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
GetConsoleScreenBufferInfo(hConsoleOutput, &screen_buffer_info);
WORD wAttributes = screen_buffer_info.wAttributes;
color &= 0x000f;
wAttributes &= 0xfff0;
wAttributes |= color;
SetConsoleTextAttribute(hConsoleOutput, wAttributes);
}
void CANIMAL::gotoXY(int x, int y)
{
HANDLE hConsoleOutput;
COORD Cursor_an_Pos = { x, y };
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput, Cursor_an_Pos);
}
void CANIMAL::ShowCur(bool CursorVisibility)
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursor = { 1, CursorVisibility };
SetConsoleCursorInfo(handle, &cursor);
}
void CANIMAL::textcolor(int x)
{
HANDLE mau;
mau = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(mau, x);
}
void CANIMAL::Set_aState(bool state)
{
this->aState = state;
}
int CANIMAL::Get_aX()
{
return this->aX;
}
int CANIMAL::Get_aY()
{
return this->aY;
}
bool CANIMAL::Get_aState()
{
return this->aState;
}
CANIMAL::~CANIMAL()
{
}
CANIMAL::CANIMAL()
{
aX = 1;
aY = 7;
aState = false;
right = false;
}
TRex::TRex()
{
aX = 78;
aY = 22;
aState = false;
right = true;
}
void CANIMAL::Move(int x0, int y0)
{
aX = x0;
aY = y0;
}
void TRex::Draw(int x0, int y0)
{
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(console, 143);
SetColor(4);
gotoXY(x0 + 1, y0 - 2);
SetColor(4);
cout << "e-e";
gotoXY(x0, y0 - 1);
cout << "(\\_/)\\";
gotoXY(x0 + 1, y0);
cout << "`-'\\_`--.___,//";
if (this->right == true)
{
gotoXY(x0 + 6, y0 + 1);
SetColor(4);
cout << "\\\\- \\\\>";
this->right = false;
}
else
{
gotoXY(x0 + 6, y0 + 1);
SetColor(4);
cout << "// -//>";
this->right = true;
}
ShowCur(0);
SetConsoleTextAttribute(console, 0);
}
void TRex::Delete(int x0, int y0)
{
gotoXY(x0 + 1, y0 - 2);
for (int i = 0; i < 3; ++i)
{
SetColor(8);
cout << char(219);
}
gotoXY(x0, y0 - 1);
for (int i = 0; i < 6; ++i)
{
SetColor(8);
cout << char(219);
}
gotoXY(x0 + 1, y0);
for (int i = 0; i < 17; ++i)
{
int z = x0 + i;
if ((z >= 4 && z <= 11) ||
(z >= 24 && z <= 31) ||
(z >= 44 && z <= 51) ||
(z >= 64 && z <= 71) ||
(z >= 84 && z <= 91))
{
gotoXY(z, y0);
SetColor(15);
cout << char(219);
}
else
{
gotoXY(z, y0);
SetColor(8);
cout << char(219);
}
}
SetColor(8);
if (this->right == false)
{
gotoXY(x0 + 6, y0 + 1);
for (int i = 0; i < 8; ++i)
cout << char(219);
}
else
{
gotoXY(x0 + 6, y0 + 1);
for (int i = 0; i < 8; ++i)
cout << char(219);
}
}
TRex::~TRex()
{
}
void CANIMAL::Set_aX(int x0)
{
aX = x0;
}
void CANIMAL::Set_aY(int y0)
{
aY = y0;
}