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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
| #include<iostream>
#include<windows.h>
#include<conio.h>
using namespace std;
const int Y = 20, X = 50;
enum DIR{UP, DOWN, LEFT, RIGHT};
void main()
{
system("title Snake by Timur Hamzin!");
setlocale(0,"RUS");
cout<<"\t\t\t\t\t __________________888\n"; Sleep(1000);
cout<<"\t\t\t\t\t 888888888888______888 \n"; Sleep(1000);
cout<<"\t\t\t\t\t 888888888888______888\n";Sleep(1000);
cout<<"\t\t\t\t\t 888888888888\n";Sleep(1500);
cout<<"\t\t\t\t\t ____8888__________888____888__888____8888\n";Sleep(1000);
cout<<"\t\t\t\t\t ____8888__________888____888888888__888888\n";Sleep(1000);
cout<<"\t\t\t\t\t ____8888__________888____888____888____888\n";Sleep(1500);
cout<<"\t\t\t\t\t ____8888__________888____888____888____888\n";Sleep(1500);
cout<<"\t\t\t\t\t ____8888__________888____888____888____888\n";Sleep(1500);
cout<<"\t\t\t\t\t ____8888__________888____888____888____888\n";Sleep(1050);
cout<<"\t\t\t\t\t ____8888__________888____888____888____888\n";Sleep(1050);
cout<<"\t\t\t\t\t ____8888__________888____888____888____888\n";Sleep(1100);
cout<<"\t\t\t\t\t ____8888__________888____888____888____888\n";Sleep(1400);
Sleep(4000);
system("cls");
cout<<"\t\t\t\t\t _888_88888_____888__88_____88888________888888______\n";
cout<<"\t\t\t\t\t _8888888888____8888888____88888888____888888888_____\n";
cout<<"\t\t\t\t\t _888____888____888_______888___8888__8888____88_____\n";
cout<<"\t\t\t\t\t _888____8888___888______888_____888__888______8_____\n";
cout<<"\t\t\t\t\t _888_____888___888______88888888888__8888888________\n";
cout<<"\t\t\t\t\t _888_____888___888______88888888888___88888888______\n";
cout<<"\t\t\t\t\t _888_____888___888______888_____________8888888_____\n";
cout<<"\t\t\t\t\t _888____8888___888______8888______8__8______888_____\n";
cout<<"\t\t\t\t\t _888____888____888_______888_____88__88_____888_____\n";
cout<<"\t\t\t\t\t _888888888_____888________888888888__888888888______\n";
cout<<"\t\t\t\t\t _888_8888______888_________8888888____8888888_______\n";
cout<<"\t\t\t\t\t _888________________________________________________\n";
cout<<"\t\t\t\t\t _888________________________________________________\n";
cout<<"\t\t\t\t\t _888________________________________________________\n";
cout<<"\t\t\t\t\t _888________________________________________________\n";
cout<<"\t\t\t\t\t ____________________________888_____________________\n";
cout<<"\t\t\t\t\t ____________________________888_____________________\n";
cout<<"\t\t\t\t\t ___88888______888__8888____8888888__________________\n";
cout<<"\t\t\t\t\t __88888888____8888888888___8888888__________________\n";
cout<<"\t\t\t\t\t _888___8888___888____888____888_____________________\n";
cout<<"\t\t\t\t\t 888_____888___888____888____888_____________________\n";
cout<<"\t\t\t\t\t 88888888888___888____888____888_____________________\n";
cout<<"\t\t\t\t\t 88888888888___888____888____888_____________________\n";
cout<<"\t\t\t\t\t 888___________888____888____888_____________________\n";
cout<<"\t\t\t\t\t 8888______8___888____888____888_____________________\n";
cout<<"\t\t\t\t\t _888_____88___888____888____888_____________________\n";
cout<<"\t\t\t\t\t __888888888___888____888_____88888__________________\n";
cout<<"\t\t\t\t\t ___8888888____888____888______8888__________________\n";
Sleep(4000);
system("cls");
cout<<"\t\t\t\t\t\t____888888\n";
cout<<"\t\t\t\t\t\t__8888888888\n";
cout<<"\t\t\t\t\t\t_88888888888\n";
cout<<"\t\t\t\t\t\t_888______88\n";
cout<<"\t\t\t\t\t\t8888___________888__8888_____8888888 \n";
cout<<"\t\t\t\t\t\t888888_________8888888888____888888888\n";
cout<<"\t\t\t\t\t\t_88888888______888____888____8_____888\n";
cout<<"\t\t\t\t\t\t__888888888____888____888__________888\n";
cout<<"\t\t\t\t\t\t___888888888___888____888______8888888\n";
cout<<"\t\t\t\t\t\t_______88888___888____888____888888888\n";
cout<<"\t\t\t\t\t\t8________888___888____888___8888___888\n";
cout<<"\t\t\t\t\t\t888______888___888____888___888____888\n";
cout<<"\t\t\t\t\t\t88888888888____888____888___888____888\n";
cout<<"\t\t\t\t\t\t8888888888_____888____888____888888888\n";
cout<<"\t\t\t\t\t\t__8888888______888____888_____8888_888 \n";
cout<<"\t\t\t\t\t\t\t_888\n";
cout<<"\t\t\t\t\t\t\t_888\n";
cout<<"\t\t\t\t\t\t\t_888\n";
cout<<"\t\t\t\t\t\t\t_888\n";
cout<<"\t\t\t\t\t\t\t_888\n";
cout<<"\t\t\t\t\t\t\t_888____888_____88888\n";
cout<<"\t\t\t\t\t\t\t_888___888_____88888888\n";
cout<<"\t\t\t\t\t\t\t_888__888_____888___8888\n";
cout<<"\t\t\t\t\t\t\t_888_8888____888_____888\n";
cout<<"\t\t\t\t\t\t\t_8888888_____88888888888\n";
cout<<"\t\t\t\t\t\t\t_8888888_____88888888888\n";
cout<<"\t\t\t\t\t\t\t_888_8888____888\n";
cout<<"\t\t\t\t\t\t\t_888__888____8888______8\n";
cout<<"\t\t\t\t\t\t\t_888___888____888_____88\n";
cout<<"\t\t\t\t\t\t\t_888___8888____888888888\n";
cout<<"\t\t\t\t\t\t\t_888____888_____8888888\n";
Sleep(8000);
system("cls");
cout<<"\t\t\t\t\t\t\t\t\t Игра начнется через ( 8 ) секунд \n\n";
Sleep(1000);
system("cls");
cout<<"\t\t\t\t\t\t\t Игра начнется через ( 7 ) секунд\n";
Sleep(1000);
system("cls");
cout<<"\t\t\t\t\t\t Игра начнется через ( 6 ) секунд\n";
Sleep(1000);
system("cls");
cout<<"\t\t\t\t\t Игра начнется через ( 5 ) секунд\n";
Sleep(1000);
system("cls");
cout<<"\t\t\t\t Игра начнется через ( 4 ) секунды\n";
Sleep(1000);
system("cls");
cout<<"\t\t\t\t\t\t Игра начнется через ( 3 ) секунды\n";
Sleep(1000);
system("cls");
cout<<"\t\t\t\t\t\t\t\t Игра начнется через ( 2 ) секунды\n";
Sleep(1000);
system("cls");
cout<<"\t\t\t\t_88888888888________________________________________\n";
cout<<"\t\t\t\t_88888888888________________________________________\n";
cout<<"\t\t\t\t_88888888888________________________________________\n";
cout<<"\t\t\t\t_888________________________________________________\n";
cout<<"\t\t\t\t_888___________888____888___888____888______________\n";
cout<<"\t\t\t\t_888___________888____888___888____888______________\n";
cout<<"\t\t\t\t_8888888888____888____888___888____888______________\n";
cout<<"\t\t\t\t_8888888888____888____888___888____888______________\n";
cout<<"\t\t\t\t_8888888888____888____888___888____88888888_________\n";
cout<<"\t\t\t\t_888___________888____888___888____8888888888_______\n";
cout<<"\t\t\t\t_888___________888____888___888____888____888_______\n";
cout<<"\t\t\t\t_888___________888____888___888____888____888_______\n";
cout<<"\t\t\t\t_88888888888___888____888___888____888____888_______\n";
cout<<"\t\t\t\t_88888888888___8888888888888888____888888888________\n";
cout<<"\t\t\t\t_88888888888___8888888888888888____88888888_________\n";
Sleep(3000);
system("cls");
int a[Y][X] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
int currScore=0,Score=200,Speed=300;
int lives = 3;//счетчик жизней
int i,j,code='w';
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coord = {25,10};// Координаты смайла
COORD coordjab={15,15};
COORD coordLives = {0,21};// Координаты вывода счетчика жизней
COORD coordScore = {0,22};// Координаты вывода счетчика Очков
COORD coordSpeed = {0,23};// Координаты вывода счетчика Очков
/////Отрисовка поля>>>
for(i=0;i<Y;i++)
{
for(j=0;j<X;j++)
{
switch(a[i][j])
{
case 1:cout << (char)177;break;
case 0:cout << ' ';break;
}
}
cout << '\n';
}
/////Отрисовка поля>>>
/////Движение червя>>>
while(code)
{
Sleep(Speed);//Задержка движения
if(_kbhit())//Если пользователь нажал клавишу
{
code = _getch();//Получаем ее код
}
else
{
SetConsoleCursorPosition(console,coord);
cout << ' ' << flush;//Стираем смайл
if(code=='w')coord.Y--;
else if(code=='s')coord.Y++;
else if(code=='a')coord.X--;
else if(code=='d')coord.X++;
}
//SetConsoleCursorPosition(console,udav[i]);
/////Движение червя>>>
/////Отрисовка яблока>>>
if(coordjab.X==coord.X && coordjab.Y==coord.Y)
{
currScore+=100;
SetConsoleCursorPosition(console,coordjab);
coordjab.X = rand() % 48+1; //
coordjab.Y = rand() % 18+1; //кординаты яблока
}
/////Отрисовка яблока>>>
if(Score==currScore)
{
Score+=300;
Speed-=10;
}
if(a[coord.Y][coord.X] == 1)
{
lives--;
coord.X = 25;
coord.Y = 10;
}
if(lives == 0)
{
system("cls");
COORD center={35,15};
SetConsoleCursorPosition(console,center);
cout << " G A M E O V E R!!!\n\n\n\n"<<flush;
_getch();
break;
}
//червь
SetConsoleTextAttribute(console, FOREGROUND_GREEN|FOREGROUND_INTENSITY);//Цвет смайла - зеленый
SetConsoleCursorPosition(console,coord);
cout << (char)1 << flush;//Выводим смайл
SetConsoleTextAttribute(console, FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_RED);//Возвращаем белый цвет
//яблоко
SetConsoleCursorPosition(console,coordjab);
SetConsoleTextAttribute(console, FOREGROUND_RED|FOREGROUND_INTENSITY);//Цвет врага - красный
cout << (char)2 << flush;//Рисуем
SetConsoleTextAttribute(console, FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_RED);//Возвращаем белый цвет
//жизни
SetConsoleCursorPosition(console,coordLives);
cout << "Lives: " << lives << flush;
SetConsoleCursorPosition(console,coordScore);
cout << "Score: " << currScore << flush;
SetConsoleCursorPosition(console,coordSpeed);
cout << "Speed: " << Speed << flush;
}//while(code)
} |