Subversion Repositories Kolibri OS

Rev

Rev 968 | Rev 1012 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
968 leency 1
/*	------- КОСИЛКА ДЛЯ КОЛИБРИ -------
2
Игра пишется на C++ (используется MS Visual C++ 6.0).
3
Это - исходник версии 1.0.
4
 
5
					 Andrey Mihaylovich aka Dron2004
6
  */
7
 
8
 
9
 
10
#include "kosSyst.h"
11
#include "kosFile.h"
12
 
13
 
14
 
15
//ВНЕШНИЕ УРОВНИ
16
bool external_levels_available=false;
17
bool external_levels = false;
18
int level_read_result;
19
Byte * externallevels;
20
Byte external_levels_count[1] = {0};
21
/////////////////
22
 
23
int lastkosilkadirection=1;
24
int laststep=0; //Последний ход. Здесь
25
				// 0 - нет такового
26
				// 1 - вниз
27
				// 2 - вверх
28
				// 3 - влево
29
				// 4 - вправо
30
 
31
 
32
Byte skindata[13824];
33
int read_result=0;
34
bool skin_available=false;
35
bool w_redraw=true;
36
 
37
const char windowTitle[]="Љ®бЁ«Є  ¤«п Љ®«ЁЎаЁ";
38
const char version[]="‚ҐабЁп 1.1";
39
int levelcount=7; //Число уровней
40
 
41
char gamearea[20][20]; //Карта
42
 
43
 
44
short int kosilkax; // Положение косилки
45
short int kosilkay;
46
short int kosilkadirection=1; //Направление прошлого шага. 1-вниз, 2-вверх, 3-влево, 4-вправо
47
short int lives=2; // Жизни
48
short int level=1; //Уровень
49
short int status=0; //Где 0 - приветствие
50
					// 1 - игра
51
					// 2 - игра пройдена
52
					// 3 - вы проиграли
53
					// 4 - выбор набора уровней (встроенный или внешний)
54
					// -1 - о программе
55
bool gamestarted=false; //Блокировка игровых клавиш. Если false - играть нельзя
56
 
57
bool drawgraphics=true; //Рисовать ли детальную графику (или ограничиться аскетичной)
969 leency 58
bool drawanimation=false; //Анимировать ли
968 leency 59
bool skinned=false;
60
int grassLeft();  //Сообщим о наличии функции Grass Left
61
 
62
//Графика игры
63
 
64
RGB kosilka_d[576];
65
RGB kosilka_l[576];
66
RGB kosilka_r[576];
67
RGB kosilka_u[576];
68
RGB grass[576];
69
RGB stone[576];
70
RGB tree[576];
71
RGB skos[576];
72
 
73
Byte kosilka_d1[]={0,1,2,3,4,5,5,6,6,6,5,5,5,5,5,6,5,5,5,4,2,2,1,7,1,2,4,6,21
74
,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,6,5,2,40,1,4,62,63,63,64,65,66,66
75
,67,66,66,66,66,68,66,66,63,69,65,65,62,4,1,2,6,75,91,64,65,67,92,75,75,75,75,75
76
,75,75,75,75,93,65,94,94,62,6,2,3,6,76,94,96,67,103,104,104,104,104,104,104,105
77
,106,107,108,109,93,63,64,75,6,3,3,21,75,94,94,67,115,104,104,104,104,105,105
78
,106,107,108,116,117,92,65,96,76,21,4,3,21,62,64,63,78,115,105,105,105,105,106
79
,107,108,116,116,119,120,92,65,96,77,6,3,4,6,62,96,69,67,123,106,106,107,107,108
80
,108,116,119,119,127,124,92,66,64,77,21,4,3,21,62,64,91,67,123,107,108,108,116
81
,116,119,119,127,127,127,124,75,69,64,77,21,4,4,6,62,64,69,68,123,108,116,119
82
,119,127,127,127,129,129,129,125,93,63,64,77,21,4,4,21,62,64,91,67,123,119,119
83
,127,127,129,129,129,129,129,129,125,68,94,64,77,6,4,3,21,62,64,94,63,122,128
84
,128,121,121,121,121,121,121,121,121,76,66,69,91,77,21,4,4,21,62,64,94,69,69,65
85
,66,67,68,68,67,68,67,67,66,66,69,91,64,77,21,4,4,21,76,96,64,94,94,64,94,96,69
86
,91,94,94,64,69,69,94,64,64,64,77,6,4,3,6,75,64,64,64,64,64,64,64,64,64,64,64,64
87
,64,64,64,64,64,96,75,21,4,3,6,16,94,64,64,64,64,64,64,64,64,64,64,64,64,64,64
88
,64,64,96,75,6,2,2,6,75,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,62
89
,6,2,1,2,33,95,111,111,111,111,79,79,79,79,79,79,79,79,111,95,79,111,95,33,32,40
90
,7,42,49,44,47,72,44,47,80,49,45,72,45,70,47,47,47,46,71,45,44,49,50,15,15,43,45
91
,72,70,71,44,71,43,44,44,46,47,71,49,71,45,47,45,47,80,80,110,0,15,45,45,45,44
92
,44,72,72,70,45,44,71,46,71,80,44,45,47,44,71,72,71,45,9,14,45,47,72,46,73,45,47
93
,72,46,45,47,45,70,43,45,45,46,47,44,43,43,42,10,8,32,42,45,46,44,43,44,44,47,45
94
,45,49,44,46,46,45,44,45,44,45,42,41,9,10,114,36,36,12,10,12,14,9,11,10,36,13,11
95
,10,9,13,12,11,9,10,8,8,8
96
};
97
 
98
Byte kosilka_u1[]={8,9,9,10,9,11,12,13,9,10,11,13,8,10,11,9,14,12,10,12,14,8,11
99
,10,9,41,42,43,44,45,44,45,46,46,44,45,45,45,47,44,44,43,44,46,45,42,32,0,14,42
100
,45,43,44,47,46,45,45,43,70,45,71,45,46,72,47,45,73,46,44,71,45,14,11,45,71,72
101
,71,44,47,45,44,80,71,46,71,44,45,70,72,72,44,44,45,45,45,15,0,110,80,80,71,45
102
,47,45,71,49,71,47,46,44,44,43,71,44,71,70,72,43,71,15,15,50,49,44,45,71,46,47
103
,47,71,70,45,72,45,49,80,47,44,72,47,44,45,50,15,1,32,121,95,111,79,95,111,79,79
104
,79,79,79,79,79,79,111,111,111,111,95,121,3,1,2,5,62,96,64,64,64,64,64,64,64,64
105
,64,64,64,64,64,64,64,96,96,75,5,2,2,6,75,94,64,64,64,64,64,64,64,64,64,64,64,64
106
,64,64,64,64,96,76,6,3,4,21,75,96,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64
107
,64,94,76,6,3,4,21,77,64,64,64,94,69,69,64,94,94,91,69,64,94,64,94,94,64,64,16
108
,21,4,4,6,77,64,91,69,66,66,66,67,67,67,68,68,67,66,65,69,69,94,64,77,21,4
109
,4,21,77,64,69,66,76,121,121,121,121,121,121,121,121,128,128,122,63,94,64,62,21
110
,3,4,6,77,64,94,67,125,129,129,129,129,129,129,127,127,119,119,123,66,91,64,62
111
,21,4,4,21,77,64,63,92,125,129,129,129,127,127,127,119,119,116,108,123,68,69,64
112
,62,6,4,4,21,77,64,63,92,124,127,127,127,119,119,116,108,108,108,108,123,68,91
113
,64,62,21,3,4,21,77,91,66,92,124,127,119,119,116,108,108,107,107,106,106,123,67
114
,69,64,62,21,3,3,21,77,64,65,92,120,119,116,116,108,107,106,105,105,105,105,115
115
,93,63,64,62,6,3,4,21,75,64,65,92,117,116,108,107,106,105,105,105,104,104,104
116
,115,67,94,96,76,21,3,3,6,75,96,63,93,109,108,107,106,105,104,104,104,104,104
117
,104,136,67,96,94,76,6,3,2,6,62,94,94,65,93,75,75,75,75,75,75,75,92,75,93,67,65
118
,64,64,75,6,2,1,4,62,65,65,69,63,65,66,67,66,66,65,65,67,66,66,65,64,63,65,62,4
119
,1,1,2,6,6,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,6,4,2,1,7,1,2,2,4,5
120
,5,6,6,5,5,5,6,6,6,6,6,5,6,3,4,2,1,0
121
};
122
 
123
Byte kosilka_l1[]={10,8,14,15,15,15,1,2,3,2,4,4,3,3,4,3,3,3,3,3,2,1,1,0,11,48,49
124
,45,47,50,3,6,6,6,21,21,21,21,6,21,21,6,21,6,5,4,2,1,29,42,71,45,74,49,33,75,76
125
,76,76,62,62,62,62,62,62,62,76,76,75,62,4,2,14,70,72,45,72,44,95,96,94,94,94,96
126
,64,64,64,64,64,96,94,94,94,66,6,3,12,46,46,44,70,47,111,64,96,96,64,94,94,91,69
127
,91,69,63,94,96,64,63,21,4,10,44,73,44,71,72,111,64,64,64,94,69,63,66,68,67,67
128
,68,67,67,65,64,21,5,12,43,45,72,44,44,111,64,64,64,94,69,122,123,123,123,123
129
,115,115,103,67,63,21,6,14,44,47,72,71,47,111,64,64,64,64,65,128,119,116,107,106
130
,105,104,104,93,66,21,6,9,44,72,70,43,80,79,64,64,64,94,66,128,119,116,108,106
131
,105,104,104,75,66,21,6,11,47,46,45,44,49,79,64,64,64,64,67,121,127,116,108,107
132
,105,104,104,92,67,21,6,10,45,45,44,44,45,79,64,64,64,69,68,121,127,119,116,107
133
,106,104,104,75,66,21,6,8,49,47,71,46,72,79,64,64,64,91,68,121,129,127,116,108
134
,106,105,104,75,66,21,6,13,45,45,46,47,45,79,64,64,64,94,67,121,129,127,119,108
135
,107,105,104,75,66,21,4,11,44,70,71,71,70,79,64,64,64,94,67,121,129,127,119,116
136
,108,106,105,75,66,21,5,10,46,43,80,49,47,79,64,64,64,64,67,121,129,129,127,119
137
,108,107,106,75,67,21,4,9,46,45,44,71,47,79,64,64,64,69,67,121,129,129,127,119
138
,116,108,107,75,66,21,6,13,45,45,45,45,47,111,64,64,64,69,66,121,129,129,127,127
139
,119,116,108,75,66,21,6,12,44,46,47,47,46,95,64,64,64,94,66,76,125,125,124,124
140
,120,117,109,93,63,21,4,11,45,47,44,45,71,79,64,64,64,64,69,66,68,92,75,92,92,92
141
,93,65,69,21,6,9,44,44,71,47,45,111,64,64,64,64,91,69,94,63,69,66,65,65,63,94,65
142
,21,4,10,47,43,72,80,44,95,64,64,64,64,64,64,64,64,64,64,64,64,64,64,63,6,2,9,42
143
,45,47,80,45,121,62,75,75,77,77,77,77,77,77,77,77,75,75,62,75,5,2,0,48,42,45,71
144
,50,2,6,6,21,6,21,21,6,21,21,21,21,21,6,6,4,2,40,8,11,51,9,8,15,1,2,2,4,4,3,4,4
145
,4,4,4,3,3,3,2,1,1,7
146
};
147
 
148
Byte kosilka_r1[]={7,1,1,2,3,3,3,4,4,4,4,4,4,4,4,2,2,1,15,0,9,12,9,8,40,2,4,6,6
149
,21,21,21,21,21,6,21,21,6,4,1,15,51,52,53,47,45,23,9,2,6,62,62,75,75,77,77,77,77
150
,77,77,77,77,77,77,78,79,45,80,47,71,42,9,2,6,65,94,94,94,96,64,64,64,64,64,64
151
,96,64,64,64,95,44,72,44,43,45,10,4,21,65,94,63,65,65,66,69,63,94,69,91,64,64,64
152
,64,79,43,47,71,44,72,9,5,21,69,65,93,92,92,92,92,92,67,66,69,64,64,64,64,79,71
153
,45,44,47,43,11,5,21,63,93,109,117,120,124,124,125,125,76,66,94,64,64,64,95,46
154
,47,47,46,72,12,6,21,65,75,108,116,119,127,127,129,129,121,66,69,64,64,64,111,47
155
,45,45,45,45,13,6,21,66,75,107,108,116,119,127,129,129,121,66,69,64,64,64,79,47
156
,71,44,45,44,9,4,21,67,75,106,107,116,119,127,129,129,121,67,64,64,64,64,79,47
157
,49,80,43,44,10,5,21,66,75,105,106,108,116,119,127,129,121,67,94,64,64,64,79,70
158
,71,71,70,72,11,4,21,66,75,104,105,107,108,119,127,129,121,67,94,64,64,64,79,45
159
,47,46,45,45,13,6,21,66,75,104,105,106,108,116,127,129,121,68,91,64,64,64,79,72
160
,46,71,47,45,8,6,21,65,75,104,104,105,107,116,119,127,121,68,69,64,64,64,79,45
161
,44,44,45,45,10,6,21,67,75,104,104,105,107,108,116,127,121,67,64,64,64,64,79,49
162
,44,45,46,46,11,6,21,66,92,104,104,105,106,108,116,119,128,66,94,64,64,64,79,80
163
,43,70,72,72,9,6,21,66,92,104,104,105,106,107,108,119,128,65,64,64,64,64,111,47
164
,71,72,47,72,14,6,21,65,67,103,115,115,123,123,123,123,122,69,94,64,64,64,111,44
165
,44,72,45,47,12,5,21,64,65,67,67,93,68,68,93,66,63,69,94,64,64,64,111,72,71,44
166
,73,72,10,3,21,63,64,96,94,63,69,91,69,91,94,94,64,64,64,64,111,47,70,44,46,44
167
,12,4,6,63,64,64,64,64,64,64,64,64,64,64,64,64,64,64,95,44,72,45,72,45,14,2,4,62
168
,75,76,76,62,62,62,62,62,62,62,76,62,62,77,79,45,43,45,46,42,36,1,2,5,6,6,21,6
169
,21,21,6,21,21,21,21,6,6,6,37,52,46,45,45,20,11,0,40,40,2,3,4,4,3,3,4,4,2,4,4,3
170
,3,2,1,15,15,15,14,36,10
171
};
172
 
173
Byte skos1[]={13,14,14,14,12,11,10,14,11,14,10,9,13,13,13,14,9,13,8,12,13,11,14
174
,8,11,10,9,8,10,10,12,11,14,10,9,14,14,9,10,12,10,14,9,11,10,8,10,8,13,14,10,8
175
,10,10,13,13,10,11,11,10,8,14,12,13,9,12,12,12,9,9,9,12,8,13,9,13,8,14,13,8,12
176
,13,11,9,11,14,9,10,10,9,14,10,8,12,12,13,9,10,14,12,14,12,9,9,8,8,10,8,12,8,14
177
,13,13,14,8,10,9,10,10,9,13,9,8,9,8,12,12,9,14,14,10,14,14,14,14,9,12,14,12,14
178
,13,10,11,51,12,13,10,14,8,8,11,13,8,8,8,9,14,12,8,13,14,14,9,14,13,9,8,126
179
,12,8,10,11,10,8,14,14,10,8,12,12,13,12,9,13,10,14,13,11,12,9,11,12,13,13,11,13
180
,12,13,13,10,8,10,14,12,11,10,11,9,14,10,11,11,11,12,9,8,9,13,14,8,8,14,10,11,9
181
,14,13,9,10,11,12,8,11,8,8,13,9,12,9,10,10,11,12,8,10,11,9,9,10,10,14,14,8,14,8
182
,13,14,9,14,11,8,12,12,14,12,14,13,9,11,8,8,14,10,9,11,12,11,10,9,9,9,11,11,14
183
,10,11,14,11,9,8,12,12,9,14,14,10,14,14,14,14,9,12,14,12,14,13,10,11,10,10,10,10
184
,8,8,8,10,13,9,12,9,12,8,8,14,11,11,13,13,12,13,12,8,11,12,13,11,12,10,13,8,8,8
185
,10,9,11,13,14,12,14,12,12,12,8,14,12,13,10,10,8,14,11,13,14,11,9,10,12,13,8,10
186
,11,13,11,11,14,9,11,8,10,14,10,14,10,12,8,8,14,14,11,13,11,12,8,8,13,12,11,14,9
187
,13,11,8,12,10,10,8,12,12,51,10,9,8,9,13,10,14,8,14,8,9,9,14,8,10,14,13,8,11,8
188
,11,13,12,13,10,13,10,10,10,9,12,11,13,14,13,11,8,14,8,10,10,10,14,13,10,11,10
189
,11,13,13,12,12,9,11,12,8,13,9,10,14,10,9,9,9,13,12,12,11,8,13,13,36,13,9,10,13
190
,12,8,13,12,9,13,10,11,12,12,10,9,13,8,9,12,10,11,12,14,9,14,14,8,11,14,12,12,10
191
,11,9,8,8,14,14,11,13,11,12,8,8,13,12,8,8,10,13,14,10,11,8,8,8,11,11,14,11,12,10
192
,13,9,14,14,9,9,11,9,10,11,8,14,12,10,12,14,9,11,10,8,13,11,10,9,13,12,11,9,10,9
193
,9,8
194
};
195
 
196
Byte grass1[]={16,17,17,18,17,19,20,21,22,22,23,22,24,18,23,23,25,18,22,26,27,28
197
,28,18,20,24,28,54,55,19,54,56,24,20,54,24,24,20,24,20,20,24,27,24,17,54,54,24
198
,55,55,28,55,55,54,54,55,54,24,54,54,24,24,54,20,54,17,54,54,55,24,81,55,17,19
199
,17,27,81,27,54,19,17,54,41,18,24,24,81,23,19,55,18,27,24,97,20,54,19,112,55,81
200
,18,24,19,24,48,20,55,28,81,28,18,24,112,55,18,81,17,54,24,54,118,19,54,81,23,81
201
,55,41,26,23,26,26,41,20,26,55,19,81,18,17,28,54,19,28,55,54,17,22,17,55,17,17
202
,81,18,28,25,97,18,27,112,112,81,24,24,27,26,81,54,24,54,17,27,55,28,23,97,25,54
203
,28,23,26,26,22,112,55,97,24,28,27,26,16,55,17,27,54,18,19,54,23,16,97,20,54,25
204
,26,26,19,19,48,18,16,28,17,23,20,19,28,55,24,20,19,28,20,48,23,33,19,97,26,26
205
,55,54,18,26,25,19,28,26,28,17,27,55,81,23,19,19,18,20,24,41,54,22,26,81,17,27
206
,17,25,26,28,24,48,22,27,26,55,54,55,55,28,16,33,5,24,41,18,48,55,19,48,97,16,26
207
,27,48,33,23,97,22,28,19,54,48,81,21,6,21,41,26,33,33,28,54,20,16,48,18,26,33,16
208
,48,23,17,19,112,26,23,48,21,21,131,48,26,33,97,17,17,20,16,25,97,16,16,26,21,20
209
,19,112,54,26,26,21,20,41,6,33,16,25,33,55,19,16,41,25,48,16,26,48,97,24,55,54
210
,24,24,23,21,23,97,48,21,33,24,6,54,54,132,54,18,16,97,28,26,22,28,27,54,20,16
211
,23,33,22,16,26,48,17,20,33,54,24,19,20,25,97,48,54,54,26,27,20,20,41,21,97,6,33
212
,23,26,48,19,17,48,24,23,24,27,16,18,16,55,55,19,26,27,54,48,21,24,48,23,33,25
213
,33,28,23,97,97,6,16,16,20,25,48,17,48,97,22,27,24,20,48,22,17,27,48,48,16,22,25
214
,24,41,33,25,25,54,23,97,17,18,27,22,97,24,20,18,23,27,17,23,48,25,23,97,27,97
215
,18,26,18,22,26,18,19,17,28,26,23,17,81,97,25,81,27,24,6,97,48,18,97,16,16,81,33
216
,18,22,26,24,17,27,23,26,17,27,23,26,26,54,41,33,18,97,22,18,22,48,18,16,97,22
217
,18,18,27,27,26,48,27,17,97,18,27,55,21,20,26,23,26,27,27,22,26,16,23,22,26,27
218
,140,19,20
219
};
220
 
221
Byte stone1[]={13,14,14,29,30,31,31,31,30,3,32,33,32,34,35,36,9,13,8,12,13,11,14
222
,8,11,10,36,30,31,57,58,57,31,59,59,59,59,31,31,30,32,29,11,11,10,8,10,8,13,8,30
223
,31,58,82,83,82,82,83,84,84,85,84,83,58,59,30,30,51,9,9,9,12,8,98,30,57,99,83,83
224
,83,83,84,84,85,100,73,49,74,73,82,31,30,8,12,12,13,9,0,30,57,82,83,83,83,83,84
225
,84,85,85,73,49,74,113,74,84,59,30,114,10,9,12,0,30,59,58,82,83,83,83,83,84,85
226
,85,73,49,74,74,113,113,83,31,30,11,10,12,13,30,30,57,99,82,83,83,83,84,84,85
227
,100,49,49,74,113,113,74,99,30,29,13,12,8,0,30,57,82,83,83,83,83,83,84,85,100,73
228
,49,74,113,113,113,85,31,40,12,13,13,1,30,99,83,83,83,83,83,83,84,84,85,73,49,74
229
,74,113,113,74,57,32,8,9,13,30,59,82,83,82,83,83,83,83,83,84,85,100,73,49,74,74
230
,113,113,57,5,51,10,0,30,57,82,82,83,83,83,83,83,83,84,85,85,73,49,74,74,113,113
231
,58,130,11,12,29,30,57,82,82,83,83,83,83,83,83,83,84,85,100,73,49,74,74,74,99,30
232
,11,9,29,30,57,82,82,83,83,83,83,83,83,83,84,84,85,73,49,49,74,74,82,30,0,8,8,30
233
,31,99,82,82,83,83,83,83,83,83,83,84,85,100,73,49,74,74,83,31,15,12,10,15,30,58
234
,82,82,82,83,83,83,83,83,83,84,84,85,100,73,49,74,84,31,1,11,13,7,30,58,82,82,82
235
,82,82,82,83,83,82,83,84,85,85,100,73,49,84,31,15,8,8,7,30,58,82,82,82,82,82,82
236
,82,82,82,83,84,84,85,85,73,73,82,30,35,10,10,35,30,57,82,82,82,82,82,82,82,82
237
,83,82,83,84,84,85,85,85,59,30,51,13,10,133,30,59,99,99,82,82,82,82,82,82,82,83
238
,82,83,84,84,84,57,30,35,10,11,13,13,1,31,58,82,99,82,82,82,99,58,58,82,82,83,83
239
,99,57,31,40,13,13,8,13,9,0,30,59,99,99,99,99,99,58,59,59,57,57,57,59,31,30,15
240
,10,11,12,14,9,14,14,15,30,31,58,58,58,57,30,30,30,30,30,30,32,1,37,8,8,13,12,8
241
,8,10,13,14,35,30,30,31,30,30,30,8,0,37,0,133,9,14,14,9,9,11,9,10,11,8,14,12,10
242
,37,40,32,1,35,8,13,11,10,9,13,12,11,9,10,9,9,8
243
};
244
 
245
Byte tree1[]={13,14,8,36,37,11,10,36,38,39,0,14,13,13,13,14,9,13,8,12,13,11,14,8
246
,11,36,39,39,39,34,38,39,60,61,60,39,34,0,37,37,14,36,15,36,14,8,10,8,11,86,60
247
,87,61,60,88,61,89,90,89,61,60,88,39,86,39,88,88,88,39,15,9,12,34,88,87,89,89
248
,101,89,89,89,89,89,89,101,61,61,90,89,89,102,87,60,39,37,13,34,60,89,89,89,89
249
,89,89,89,89,89,89,89,89,89,89,89,89,89,89,102,88,7,11,15,88,102,101,89,89,89,89
250
,89,89,101,89,89,101,89,89,89,89,89,89,101,60,34,51,8,39,60,102,89,89,89,89,89
251
,90,102,101,89,101,101,89,89,89,89,89,101,60,39,51,37,34,60,90,101,89,89,101,89
252
,101,101,89,89,89,89,89,89,89,89,89,89,87,88,15,37,60,89,89,89,89,101,90,89,89
253
,89,89,89,89,89,89,89,89,89,89,89,101,102,88,39,102,89,89,89,89,101,90,89,89,89
254
,89,89,89,101,101,101,101,89,89,89,89,89,61,32,102,89,89,89,89,101,90,90,101,89
255
,89,89,101,87,101,89,89,89,89,89,89,89,102,39,61,89,89,89,89,89,89,101,102,101
256
,89,89,90,89,89,89,89,89,89,89,89,89,90,9,39,61,101,89,89,89,89,101,102,102,89
257
,101,101,89,89,89,89,89,89,89,89,89,102,36,34,88,102,89,89,89,89,89,101,101,89
258
,89,89,89,89,89,89,89,89,89,101,90,60,8,39,60,101,89,89,89,89,89,89,89,89,89,89
259
,89,89,89,89,89,89,89,101,101,60,34,88,101,89,89,89,89,89,89,89,89,89,89,89,89
260
,89,89,89,89,101,101,89,89,102,34,60,89,89,89,89,89,89,89,89,89,89,89,89,89,89
261
,89,89,101,90,101,89,89,101,34,88,87,89,89,101,89,89,89,89,90,102,89,89,89,89,89
262
,89,89,89,101,89,89,102,37,32,60,102,87,87,89,89,89,134,135,135,101,89,89,89,89
263
,89,89,89,101,102,102,60,11,51,37,38,34,88,61,102,61,39,137,131,134,101,101,101
264
,102,90,89,89,102,60,39,37,8,51,11,37,37,0,39,39,32,15,137,137,138,60,61,60,88
265
,88,102,102,60,39,40,10,11,9,14,8,8,36,40,36,51,51,137,137,137,34,39,34,29,38,39
266
,39,32,15,13,12,8,8,10,51,14,37,37,8,8,8,137,137,137,8,9,139,51,8,7,7,14,11,11,9
267
,10,11,8,14,51,10,12,14,11,11,137,137,137,11,10,9,13,51,14,11,51,9,9,8
268
};
269
 
270
 
271
//Палитра цветов. Декодируем в 0xRRGGBB
272
 
273
char * apppath;
274
char * levpath;
275
char * getSkinPathName(){
276
 
277
	int lastslashindex=0;
278
	static char skinfilename[]="kosskin.gfx";
279
	int tempslfnd=0;
280
 
281
	for (tempslfnd=0; tempslfnd < strlen(kosExePath); tempslfnd++){
282
			if (kosExePath[tempslfnd]=='/'){lastslashindex=tempslfnd;}
283
	}
284
 
285
	apppath = new char[lastslashindex+strlen(skinfilename)+1];
286
 
287
	for (tempslfnd=0; tempslfnd <= lastslashindex; tempslfnd++){
288
		apppath[tempslfnd]=kosExePath[tempslfnd];
289
	}
290
	for (tempslfnd=0; tempslfnd < strlen(skinfilename); tempslfnd++){
291
		apppath[tempslfnd+lastslashindex+1]=skinfilename[tempslfnd];
292
	}
293
 
294
 
295
	return apppath;
296
 
297
 
298
}
299
 
300
char * getLevelsPathName(){
301
 
302
	int lastslashindex=0;
303
	static char levfilename[]="koslevel.pak";
304
	int tempslfnd=0;
305
 
306
	for (tempslfnd=0; tempslfnd < strlen(kosExePath); tempslfnd++){
307
			if (kosExePath[tempslfnd]=='/'){lastslashindex=tempslfnd;}
308
	}
309
 
310
	levpath = new char[lastslashindex+strlen(levfilename)+1];
311
 
312
	for (tempslfnd=0; tempslfnd <= lastslashindex; tempslfnd++){
313
		levpath[tempslfnd]=kosExePath[tempslfnd];
314
	}
315
	for (tempslfnd=0; tempslfnd < strlen(levfilename); tempslfnd++){
316
		levpath[tempslfnd+lastslashindex+1]=levfilename[tempslfnd];
317
	}
318
 
319
	return levpath;
320
 
321
 
322
}
323
 
324
 
325
void decode_graphics(Byte * source, RGB * target){
326
	static RGB palette[] = {
327
		0x978A31,0x8B7F2E,0x867B2B,0x82762B,0x7F7428,0x79702B,0x766C26,0x90832E,
328
		0x978A2F,0x9A8C31,0x9B8D32,0x998C31,0x9C8E33,0x9D8F34,0x988B30,0x928531,
329
		0x887532,0xBAA454,0xA18C3D,0xC6B26A,0xA08E46,0x6B5F26,0xAF9844,0x9C873B,
330
		0xAB964D,0x988338,0xA89140,0xB49D4C,0xC1AC5C,0x94872F,0x303030,0x343435,
331
		0x827933,0x806E2F,0x8B8134,0x938632,0x96892F,0x988C33,0x8F873B,0x7E9F39,
332
		0x8E812D,0x92803F,0x75715C,0x676462,0x6D6A68,0x666260,0x6B6866,0x6A6664,
333
		0x8E7B35,0x626161,0x797641,0x9B8E33,0x7F7954,0x776A67,0xB29E55,0xBCA75E,
334
		0x978C3E,0x3E3E3D,0x434245,0x373938,0x3C9737,0x209437,0xB97934,0xE6863E,
335
		0xF28C41,0xE2833D,0xDD803B,0xD77C3A,0xD17938,0xEA883F,0x605D5B,0x686563,
336
		0x706D6B,0x5F5F5E,0x656566,0xB56931,0xAC663B,0xC17D36,0xC88338,0x997246,
337
		0x737271,0xA89546,0x4D4D4E,0x515152,0x565656,0x5A5A59,0x687B41,0x098933,
338
		0x5B9B38,0x009036,0x069136,0xF18B41,0xC27034,0xCD7737,0xEE8A40,0xA0774B,
339
		0xF18C41,0x948037,0x988B34,0x49484A,0x5D5D5D,0x039036,0x0E9236,0xB06B7B,
340
		0x949CF8,0x7C85F6,0x6A74F5,0x5A66F4,0x4653F1,0x5F53B6,0x726462,0x9C7449,
341
		0xD0C472,0x696969,0x998B32,0x9D6676,0x3B47DD,0x5349A0,0xD8CD77,0x343EC1,
342
		0x4F438C,0x8E5538,0xC37341,0x895D71,0x483B74,0x433359,0x9C8D34,0x2A329A,
343
		0x995F49,0x1D236D,0x756E37,0x524819,0x8D8848,0x9B8D34,0x157F2F,0x2D6C28,
344
		0xAA778B,0x663C15,0x4E5924,0x9D8F31,0xBCAD48
345
	};
346
 
347
	for (int lc=0;lc<576;lc++)
348
		target[lc] = palette[source[lc]];
349
}
350
 
351
 
352
void interlevelpause(){ //Пауза между уровнями
353
	Byte tempCode;
354
	RGB tmprgb;
355
	int tmpa=0;
356
	laststep=0;
357
	static int yellow_pal[] = {0xA8A93D,0xBEBF4C,0xD6D856,0xDFE15A,0xECEE5B,
358
						    0xECEE5B,0xDFE15A,0xD6D856,0xBEBF4C,0xA8A93D};
359
		for (int iic=0;iic<240;iic++){
360
			kos_WaitForEvent(1);
361
			kos_GetKey(tempCode);
362
 
363
			kos_DrawBar(iic*2,0,2,480,yellow_pal[tmpa]);
364
 
365
			tmpa++;
366
			if (tmpa>9){tmpa=0;}
367
		}
368
}
369
 
370
void draw_element(int elx, int ely){ //Отрисовка элемента карты
371
switch (gamearea[elx][ely]){
372
			case 'g':
373
				if (drawgraphics==true){
374
					kos_PutImage((RGB*)grass,24,24,elx*24,ely*24);
375
				}
376
				else
377
				{
378
					kos_DrawBar(elx*24,ely*24,24,24,0xAAAA00);
379
				}
380
 
381
				break;
382
			case 'k':
383
				if (drawgraphics==true){
384
					switch(kosilkadirection){
385
					case 1:
386
						kos_PutImage((RGB*)kosilka_d,24,24,elx*24,ely*24);
387
						break;
388
					case 2:
389
						kos_PutImage((RGB*)kosilka_u,24,24,elx*24,ely*24);
390
						break;
391
					case 3:
392
						kos_PutImage((RGB*)kosilka_l,24,24,elx*24,ely*24);
393
						break;
394
					case 4:
395
						kos_PutImage((RGB*)kosilka_r,24,24,elx*24,ely*24);
396
						break;
397
					}
398
 
399
 
400
				}
401
				else
402
				{
403
					kos_DrawBar(elx*24,ely*24,24,24,0x00AAAA);
404
				}
405
 
406
 
407
 
408
				break;
409
			case 'n':
410
				if (drawgraphics==true){
411
					kos_PutImage((RGB*)skos,24,24,elx*24,ely*24);
412
				}
413
				else
414
				{
415
					kos_DrawBar(elx*24,ely*24,24,24,0xAAAAAA);
416
				}
417
 
418
 
419
				break;
420
			case 's':
421
				if (drawgraphics==true){
422
					kos_PutImage((RGB*)stone,24,24,elx*24,ely*24);
423
				}
424
				else
425
				{
426
					kos_DrawBar(elx*24,ely*24,24,24,0x555555);
427
				}
428
 
429
 
430
				break;
431
 
432
			case 't':
433
				if (drawgraphics==true){
434
					kos_PutImage((RGB*)tree,24,24,elx*24,ely*24);
435
				}
436
				else
437
				{
438
					kos_DrawBar(elx*24,ely*24,24,24,0x005500);
439
				}
440
 
441
 
442
				break;
443
 
444
			}
445
 
446
}
447
 
448
 
449
void display_grass_left(){ //Выводим на экран количество оставшейся травы
450
	kos_DrawBar(605,120,20,10,0xEEEEEE);
451
	kos_DisplayNumberToWindow(grassLeft(),3,605,120,0x0000FF,nbDecimal,false);
452
}
453
 
454
 
455
void animate(int initcellx, int initcelly, int direction){ //анимация движения косилки
456
	int tmpp=0;
457
 
458
		switch (direction){
459
		case 1:
460
			for (tmpp=0; tmpp<23;tmpp++){
461
				if (drawgraphics==true){
462
					kos_PutImage((RGB*)skos,24,24,initcellx*24,initcelly*24);
463
					kos_PutImage((RGB*)kosilka_d,24,24,initcellx*24,initcelly*24+tmpp);
464
				} else {
465
					kos_DrawBar(initcellx*24,initcelly*24,24,24,0xAAAAAA);
466
					kos_DrawBar(initcellx*24,initcelly*24+tmpp,24,24,0x00AAAA);
467
 
468
				}
469
				kos_Pause(1);
470
			}
471
			break;
472
		case 2:
473
			for (tmpp=0; tmpp<23;tmpp++){
474
				if (drawgraphics==true){
475
					kos_PutImage((RGB*)skos,24,24,initcellx*24,initcelly*24);
476
					kos_PutImage((RGB*)kosilka_u,24,24,initcellx*24,initcelly*24-tmpp);
477
				} else {
478
					kos_DrawBar(initcellx*24,initcelly*24,24,24,0xAAAAAA);
479
					kos_DrawBar(initcellx*24,initcelly*24-tmpp,24,24,0x00AAAA);
480
				}
481
				kos_Pause(1);
482
			}
483
			break;
484
		case 3:
485
			for (tmpp=0; tmpp<23;tmpp++){
486
				if (drawgraphics==true){
487
					kos_PutImage((RGB*)skos,24,24,initcellx*24,initcelly*24);
488
					kos_PutImage((RGB*)kosilka_r,24,24,initcellx*24+tmpp,initcelly*24);
489
				} else {
490
					kos_DrawBar(initcellx*24,initcelly*24,24,24,0xAAAAAA);
491
					kos_DrawBar(initcellx*24+tmpp,initcelly*24,24,24,0x00AAAA);
492
 
493
				}
494
				kos_Pause(1);
495
			}
496
			break;
497
		case 4:
498
			for (tmpp=0; tmpp<23;tmpp++){
499
				if (drawgraphics==true){
500
					kos_PutImage((RGB*)skos,24,24,initcellx*24,initcelly*24);
501
					kos_PutImage((RGB*)kosilka_l,24,24,initcellx*24-tmpp,initcelly*24);
502
				} else {
503
					kos_DrawBar(initcellx*24,initcelly*24,24,24,0xAAAAAA);
504
					kos_DrawBar(initcellx*24-tmpp,initcelly*24,24,24,0x00AAAA);
505
 
506
				}
507
				kos_Pause(1);
508
			}
509
			break;
510
		}
511
 
512
 
513
}
514
 
515
 
516
void draw_window(void){ //Перерисовка окна
517
	//----Leency
518
	if (w_redraw)
519
	{
520
		kos_WindowRedrawStatus(1); //Начало перерисовки
969 leency 521
		//kos_DefineAndDrawWindow(50,50,640,506,0x74,0xEEEEEE,0,0,(Dword)windowTitle);
522
		kos_DefineAndDrawWindow(50,50,640,506-22+kos_GetSkinWidth(),0x74,0xEEEEEE,0,0,(Dword)windowTitle);
968 leency 523
	}
524
	w_redraw=false;
525
 
526
 
527
	//Перерисовка карты
528
	if ((status!=0)&&(status!=-1)&&(status!=4))
529
	{
530
		kos_DrawBar(631-151,0,151,480,0xEEEEEE);
531
 
532
		kos_WriteTextToWindow(505,30,0x80, 0 ,"Љ  Ћ  ‘  €  ‹  Љ  Ђ",19);
533
		kos_WriteTextToWindow(522,40,0x80, 0 ,"¤«п Љ®«ЁЎаЁ Ћ‘",14);
534
 
535
		kos_WriteTextToWindow(495,80,0x80, 0 ,"“а®ўҐ­м:",6);
536
		kos_DisplayNumberToWindow(level,3,605,80,0x0000FF,nbDecimal,false);
537
 
538
		kos_WriteTextToWindow(495,95,0x80, 0 ,"Ћбв «®бм Ї®Їлв®Є:",11);
539
		kos_DisplayNumberToWindow(lives,1,605,95,0x0000FF,nbDecimal,false);
540
 
541
		kos_WriteTextToWindow(495,120,0x80, 0 ,"Ћбв «®бм ва ўл:",11);
542
		display_grass_left();
543
 
544
		kos_WriteTextToWindow(526,450,0x80, 0 ,(char*)version,12);
545
 
546
		for (int cy=0;cy<20;cy++) for (int cx=0;cx<20;cx++)	draw_element(cx,cy);
547
	}
548
 
549
	if (status==0){
550
		kos_DrawBar(0,0,4,480,0x000000);
551
		kos_DrawBar(628,0,3,480,0x000000);
552
		//Leency----
553
 
554
 
555
		for (int tmpppy=0;tmpppy<20;tmpppy++){
556
			for (int tmpppx=0;tmpppx<26;tmpppx++){
557
				if ((tmpppx==0) || (tmpppx==25) || (tmpppy==0) || (tmpppy==19)){
558
					kos_PutImage((RGB*)stone,24,24,4+tmpppx*24,tmpppy*24);
559
				}
560
				else
561
				{
562
					kos_PutImage((RGB*)skos,24,24,4+tmpppx*24,tmpppy*24);
563
				}
564
			}
565
		}
566
 
567
		if (drawgraphics==true){
568
			kos_PutImage((RGB*)kosilka_d,24,24,305,150);
569
		}
570
		else
571
		{
572
			kos_DrawBar(305,150,24,24,0x00AAAA);
573
		}
574
 
575
 
576
		if (drawanimation==true){
577
			kos_DrawBar(335,150,24,24,0x00AA00);
578
		}
579
		else
580
		{
581
			kos_DrawBar(335,150,24,24,0xAA0000);
582
		}
583
 
584
                kos_WriteTextToWindow(257,200,0x80, 0xFFFFFF ,"Љ   Ћ   ‘   €   ‹   Љ   Ђ",19);
585
                kos_WriteTextToWindow(290, 220,0x80, 0xFFFFFF ,"¤«п Љ®«ЁЎаЁ Ћ‘",14);
586
                kos_WriteTextToWindow(239, 240,0x80, 0xFFFFFF ,"<¤«п ­ з «  ЁЈал ­ ¦¬ЁвҐ ENTER>",30);
587
                kos_WriteTextToWindow(30, 380,0x80, 0xFFFFFF ,"<­ ¦¬ЁвҐ  ¤«п ЇҐаҐЄ«о祭Ёп ०Ё¬  Ја дЁЄЁ>",53);
588
                kos_WriteTextToWindow(30, 400,0x80, 0xFFFFFF ,"<­ ¦¬ЁвҐ  ¤«п ўЄ«о祭Ёп/ўлЄ«о祭Ёп  ­Ё¬ жЁЁ>",41);
589
                kos_WriteTextToWindow(30, 420,0x80, 0xFFFFFF ,"<­ ¦¬ЁвҐ  ¤«п Їа®б¬®ва  бўҐ¤Ґ­Ё© ® Їа®Ја ¬¬Ґ>",32);
590
                if (skin_available==true) {kos_WriteTextToWindow(30, 440,0x80, 0xFFFFFF ,"<­ ¦¬ЁвҐ  зв®Ўл ўлЄ«озЁвм/ўЄ«озЁвм бЄЁ­>",27);}
591
 
592
 
593
        //      kos_WriteTextToWindow(470, 440,0x80, 0xFFFFFF ,"­ ¦¬ЁвҐ  ¤«п ўл室 ",27);
594
	//	kos_DisplayNumberToWindow(external_levels_count[0],3,200,340,0x0000FF,nbDecimal,false);
595
 
596
 
597
 
598
		kos_WriteTextToWindow(536, 440,0x80, 0xFFFFFF ,(char*)version,0);
599
	}
600
	if (status==2){
601
	   kos_DrawBar(10,150,610,200,0x528B4C);
602
	   kos_DrawBar(15,155,601,190,0x3BCF46);
603
           kos_WriteTextToWindow(240,230,0x80, 0xFFFFFF ,"‚л ўлЁЈа «Ё!",13);
604
           kos_WriteTextToWindow(240,250,0x80, 0xFFFFFF ,"<­ ¦¬ЁвҐ q ¤«п ў®§ўа в  ў ¬Ґ­о>",17);
605
	}
606
	if (status==3){
607
	   kos_DrawBar(10,150,610,200,0x8B4C4C);
608
	   kos_DrawBar(15,155,601,190,0xCF3B3B);
609
           kos_WriteTextToWindow(220,220,0x80, 0xFFFFFF ,"€Ја  ®Є®­зҐ­ ...",13);
610
           kos_WriteTextToWindow(220,240,0x80, 0xFFFFFF ,"<­ ¦¬ЁвҐ r ¤«п в®Ј®, зв®Ўл блЈа вм Ґйс а §>",23);
611
           kos_WriteTextToWindow(220,260,0x80, 0xFFFFFF ,"<­ ¦¬ЁвҐ q ¤«п ў®§ўа в  ў ¬Ґ­о>",17);
612
	}
613
	if (status==-1){
614
 
615
		kos_DrawBar(0,0,4,480,0x000000);
616
		kos_DrawBar(631-3,0,3,480,0x000000);
617
 
618
	   for (int tmpppy=0;tmpppy<20;tmpppy++){
619
			for (int tmpppx=0;tmpppx<26;tmpppx++){
620
				if ((tmpppx==0) || (tmpppx==25) || (tmpppy==0) || (tmpppy==19)){
621
					kos_PutImage((RGB*)stone,24,24,4+tmpppx*24,tmpppy*24);
622
				}
623
				else
624
				{
625
					kos_PutImage((RGB*)skos,24,24,4+tmpppx*24,tmpppy*24);
626
				}
627
			}
628
		}
629
 
630
           kos_WriteTextToWindow(40,40,0x80, 0xFFFFFF ,"Љ®бЁ«Є  ¤«п Ћ‘ Љ®«ЁЎаЁ",22);
631
	   kos_WriteTextToWindow(40,60,0x80, 0xFFFFFF ,(char*)version,12);
632
	   kos_WriteTextToWindow(40,75,0x80, 0xFFFFFF ,"________________________________________",40);
633
 
634
           kos_WriteTextToWindow(40,120,0x80, 0xFFFFFF ,"Љ®««ҐЄвЁў а §а Ў®взЁЄ®ў:",18);
635
           kos_WriteTextToWindow(40,150,0x80, 0xEEFFEE ,"Ђ­¤аҐ© ЊЁе ©«®ўЁз aka Dron2004 - Їа®Ја ¬¬Ёа®ў ­ЁҐ, ўбв஥­­ п Ја дЁЄ  (ЎҐ§ бЄЁ­ )",32);
636
           kos_WriteTextToWindow(40,170,0x80, 0xDDFFDD ,"Mario79 - вҐбвЁа®ў ­ЁҐ, Ї®¬®йм ў а §а Ў®вЄҐ, ў ¦­лҐ Ё¤ҐЁ",35);
637
           kos_WriteTextToWindow(40,190,0x80, 0xCCFFCC ,"Ataualpa - вҐбвЁа®ў ­ЁҐ, Ї®¬®йм ў а §а Ў®вЄҐ",36);
638
           kos_WriteTextToWindow(40,210,0x80, 0xBBFFBB ,"Leency - вҐбвЁа®ў ­ЁҐ, Ї®¬®йм ў а §а Ў®вЄҐ, § ¬Ґз вҐ«м­лҐ бЄЁ­л, ў ¦­лҐ Ё¤ҐЁ",62);
639
           kos_WriteTextToWindow(40,230,0x80, 0xAAFFAA ,"Mike - вҐбвЁа®ў ­ЁҐ, Ї®¬®йм ў а §а Ў®вЄҐ",34);
640
           kos_WriteTextToWindow(40,250,0x80, 0x99FF99 ,"bw - вҐбвЁа®ў ­ЁҐ, Ї®¬®йм ў а §а Ў®вЄҐ, ў ¦­лҐ Ё¤ҐЁ",49);
641
			kos_WriteTextToWindow(40,270,0x80, 0x99FF99 ,"diamond - Ё¤Ґп ®в¬Ґ­л 室 , вҐбвЁа®ў ­ЁҐ",49);
642
 
643
           kos_WriteTextToWindow(40,300,0x80, 0x88FF88 ,"Ћв¤Ґ«м­®Ґ бЇ бЁЎ®:",16);
644
           kos_WriteTextToWindow(40,330,0x80, 0x77FF77 ,"‚ᥬ, Єв® ЁЈа Ґв ў нвг ЁЈаг :-) !",50);
645
 
646
 
647
           kos_WriteTextToWindow(40,430,0x80, 0x66FF66 ,"­ ¦¬ЁвҐ  ¤«п ў®§ўа в  ў ¬Ґ­о",35);
648
	}
649
 
650
 
651
	if (status==4){
652
		kos_DrawBar(0,0,631,480,0x000000);
653
 
654
 
655
		for (int tmpppy=0;tmpppy<20;tmpppy++){
656
			for (int tmpppx=0;tmpppx<26;tmpppx++){
657
				if ((tmpppx==0) || (tmpppx==25) || (tmpppy==0) || (tmpppy==19)){
658
					kos_PutImage((RGB*)stone,24,24,4+tmpppx*24,tmpppy*24);
659
				}
660
				else
661
				{
662
					kos_PutImage((RGB*)skos,24,24,4+tmpppx*24,tmpppy*24);
663
				}
664
			}
665
		}
666
 
667
                kos_WriteTextToWindow(215, 200,0x80, 0xFFFFFF ,"‚лЎҐаЁвҐ ­ Ў®а га®ў­Ґ© (­ ¦¬ЁвҐ <1> Ё«Ё <2>):",0);
668
                kos_WriteTextToWindow(215, 220,0x80, 0xFFFFFF ,"1. ‚бв஥­­лҐ га®ў­Ё",0);
669
                kos_WriteTextToWindow(215, 240,0x80, 0xFFFFFF ,"2. ‚­Ґи­Ё© ­ Ў®а га®ў­Ґ©",0);
670
 
671
	}
672
 
673
 
674
	kos_WindowRedrawStatus(2); //Конец перерисовки
675
 
676
}
677
 
678
 
679
 
680
//Описание уровней игры
681
//, где	k - косилка
682
//		g - трава
683
//		n - скошенная трава
684
//		s - камень
685
//		t - дерево
686
void initializeLevel(int levnum){
687
	laststep=0;
688
	if (external_levels==false){
689
 
690
	kosilkadirection=1;
691
	if (levnum==1){
692
		static char tmparea[20][20]={{'k','t','g','g','g','g','g','s','g','g','g','g','g','g','g','g','g','g','g','g'},
693
								{'g','s','g','s','g','g','g','s','g','s','g','g','s','g','g','g','g','g','g','g'},
694
								{'g','t','g','s','g','g','g','s','g','s','g','g','s','g','g','g','g','g','g','g'},
695
								{'g','s','g','s','g','g','g','s','g','s','g','g','s','g','g','g','g','g','g','g'},
696
								{'g','t','g','s','g','g','g','s','g','s','g','g','s','g','g','g','g','g','g','g'},
697
								{'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
698
								{'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','s','s','s','g','g'},
699
								{'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','s','s','s','g','g'},
700
								{'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','s','s','s','g','g'},
701
								{'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','s','g','g','g','g'},
702
								{'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
703
								{'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
704
								{'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
705
								{'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
706
								{'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
707
								{'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
708
								{'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
709
								{'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
710
								{'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
711
								{'g','g','g','s','g','g','g','g','g','s','g','g','s','g','g','g','g','g','g','g'}};
712
			for (int tyy=0;tyy<20;tyy++){
713
				for (int txx=0;txx<20;txx++){
714
 
715
					if (tmparea[txx][tyy]=='k'){
716
						kosilkax=tyy;
717
						kosilkay=txx;
718
					}
719
 
720
					gamearea[txx][tyy]=tmparea[tyy][txx];
721
				}
722
			}
723
	}
724
	if (levnum==2){
725
		static char tmparea[20][20]={{'s','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
726
								{'s','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','s','g'},
727
								{'g','k','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','s','g'},
728
								{'g','g','g','g','g','g','g','g','g','g','g','g','s','s','g','g','g','g','g','g'},
729
								{'g','g','g','g','g','g','g','g','g','g','g','g','s','s','g','g','g','g','g','g'},
730
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
731
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
732
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
733
								{'s','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
734
								{'s','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
735
								{'g','g','g','g','g','g','g','g','s','s','g','g','g','g','g','g','g','s','s','g'},
736
								{'g','g','g','g','g','g','g','g','s','s','g','g','g','g','g','g','g','s','s','g'},
737
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
738
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
739
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','s','s','g','g','g','g','g'},
740
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','s','s','g','g','g','g','g'},
741
								{'g','g','g','s','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
742
								{'g','g','g','s','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
743
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
744
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'}};
745
			for (int tyy=0;tyy<20;tyy++){
746
				for (int txx=0;txx<20;txx++){
747
 
748
					if (tmparea[txx][tyy]=='k'){
749
						kosilkax=tyy;
750
						kosilkay=txx;
751
					}
752
 
753
					gamearea[txx][tyy]=tmparea[tyy][txx];
754
				}
755
			}
756
	}
757
 
758
	if (levnum==3){
759
		static char tmparea[20][20]={{'t','n','t','n','t','n','t','n','t','n','t','n','t','n','t','n','t','n','t','k'},
760
								{'n','t','g','g','g','g','g','g','g','g','g','g','s','n','n','s','n','s','t','g'},
761
								{'t','n','g','g','g','g','g','g','g','g','g','g','n','t','n','n','n','t','t','g'},
762
								{'n','t','g','g','g','g','g','g','g','g','g','g','n','s','n','s','n','s','t','g'},
763
								{'t','n','g','g','g','g','g','s','s','g','g','g','n','n','n','n','n','t','t','g'},
764
								{'n','t','g','g','g','g','g','g','g','g','g','g','t','n','s','n','n','s','t','g'},
765
								{'t','n','g','g','g','g','g','g','g','g','g','g','n','n','n','n','n','t','t','g'},
766
								{'n','t','g','g','g','g','g','g','g','g','g','g','n','n','s','n','n','s','t','g'},
767
								{'t','n','g','g','g','g','g','g','g','g','g','g','n','s','n','n','n','t','t','g'},
768
								{'n','t','g','g','g','g','g','g','g','g','g','g','s','n','n','n','n','t','g','g'},
769
								{'t','n','g','g','g','s','g','g','g','g','g','g','t','t','t','t','t','t','g','g'},
770
								{'n','t','g','g','g','s','g','g','g','g','g','g','g','g','g','g','g','t','g','g'},
771
								{'t','n','g','g','g','g','g','g','g','g','g','g','t','t','g','g','g','t','g','g'},
772
								{'n','t','g','g','g','g','g','g','t','t','g','g','g','t','g','g','g','t','g','g'},
773
								{'t','n','g','g','g','g','g','g','t','t','g','g','g','t','g','g','g','t','g','g'},
774
								{'n','t','g','g','g','g','g','g','g','g','g','g','g','t','g','g','g','t','g','g'},
775
								{'t','n','g','g','g','g','g','g','g','g','g','g','g','t','t','g','g','t','g','g'},
776
								{'n','t','g','g','g','g','g','g','g','g','g','g','g','g','t','g','g','t','g','g'},
777
								{'t','n','g','g','g','g','g','g','g','g','g','g','g','g','t','g','g','t','g','g'},
778
								{'n','t','s','s','s','s','s','s','s','s','s','s','s','s','t','g','g','g','g','g'}};
779
			for (int tyy=0;tyy<20;tyy++){
780
				for (int txx=0;txx<20;txx++){
781
 
782
					if (tmparea[txx][tyy]=='k'){
783
						kosilkax=tyy;
784
						kosilkay=txx;
785
					}
786
 
787
					gamearea[txx][tyy]=tmparea[tyy][txx];
788
				}
789
			}
790
	}
791
 
792
		if (levnum==4){
793
		static char tmparea[20][20]={{'t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t'},
794
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','n','t'},
795
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','n','t'},
796
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','n','t'},
797
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','s','n','t'},
798
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','s','n','t'},
799
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','s','n','t'},
800
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','s','n','t'},
801
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','s','s','t'},
802
								{'t','g','g','g','g','t','t','t','t','t','t','t','t','g','g','g','g','g','g','t'},
803
								{'t','g','g','g','g','t','t','t','t','t','t','t','t','g','g','g','g','g','g','t'},
804
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','t'},
805
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','t'},
806
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','t'},
807
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','t'},
808
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','t'},
809
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
810
								{'t','k','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
811
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
812
								{'t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t'}};
813
			for (int tyy=0;tyy<20;tyy++){
814
				for (int txx=0;txx<20;txx++){
815
 
816
					if (tmparea[txx][tyy]=='k'){
817
						kosilkax=tyy;
818
						kosilkay=txx;
819
					}
820
 
821
					gamearea[txx][tyy]=tmparea[tyy][txx];
822
				}
823
			}
824
	}
825
 
826
			if (levnum==5){
827
		static char tmparea[20][20]={{'t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t'},
828
								{'t','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
829
								{'t','t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
830
								{'t','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
831
								{'t','s','g','g','g','g','g','t','g','g','t','g','g','g','g','g','g','g','g','t'},
832
								{'t','t','g','g','g','g','t','n','t','t','t','g','g','g','g','g','g','g','g','t'},
833
								{'t','s','g','g','g','g','t','n','n','n','t','g','g','g','g','g','g','g','g','t'},
834
								{'t','k','g','g','g','g','t','n','n','n','t','g','g','g','g','g','g','g','g','t'},
835
								{'t','g','g','g','g','g','t','n','n','n','t','g','g','g','g','g','g','g','g','t'},
836
								{'t','g','g','g','g','g','t','n','n','t','g','g','g','g','g','g','g','g','g','t'},
837
								{'t','g','g','g','g','g','t','n','n','t','g','g','g','g','g','g','g','g','g','t'},
838
								{'t','g','g','g','g','g','t','n','n','n','t','g','g','g','g','g','g','g','g','t'},
839
								{'t','g','g','g','g','g','t','n','n','n','t','g','g','g','g','g','g','g','g','t'},
840
								{'t','g','g','g','g','g','g','t','n','t','t','g','g','g','g','g','g','g','g','t'},
841
								{'t','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','g','t'},
842
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
843
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
844
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
845
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
846
								{'t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t'}};
847
			for (int tyy=0;tyy<20;tyy++){
848
				for (int txx=0;txx<20;txx++){
849
 
850
					if (tmparea[txx][tyy]=='k'){
851
						kosilkax=tyy;
852
						kosilkay=txx;
853
					}
854
 
855
					gamearea[txx][tyy]=tmparea[tyy][txx];
856
				}
857
			}
858
			}
859
 
860
		if (levnum==6){
861
		static char tmparea[20][20]={{'s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s'},
862
								{'s','k','t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
863
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
864
								{'s','g','g','s','s','s','s','s','s','s','s','s','s','s','s','s','s','g','g','s'},
865
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','t','t','s','g','g','s'},
866
								{'s','g','g','s','g','g','g','g','g','g','g','g','g','g','t','t','s','g','g','s'},
867
								{'s','g','g','s','g','g','g','g','g','g','g','g','g','g','t','t','s','g','g','s'},
868
								{'s','g','g','s','g','g','g','g','g','t','t','g','g','g','g','g','s','g','g','s'},
869
								{'s','g','g','s','g','g','g','g','g','t','t','t','g','g','g','g','s','g','g','s'},
870
								{'s','g','g','s','g','g','g','t','t','t','t','t','t','g','g','g','s','g','g','s'},
871
								{'s','g','g','s','g','g','g','t','t','t','t','t','t','g','g','g','s','g','g','s'},
872
								{'s','g','g','s','g','g','g','g','g','t','t','g','g','g','g','g','s','g','g','s'},
873
								{'s','g','g','s','g','g','g','g','g','t','t','g','g','g','g','g','s','g','g','s'},
874
								{'s','g','g','s','g','g','g','g','g','g','g','g','g','g','g','g','s','g','g','s'},
875
								{'s','g','g','s','g','g','g','g','g','g','g','g','g','g','g','g','s','g','g','s'},
876
								{'s','g','g','s','g','g','g','g','g','g','g','g','g','g','g','g','s','g','g','s'},
877
								{'s','g','g','s','s','s','s','s','s','s','s','s','s','s','s','s','s','g','g','s'},
878
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
879
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
880
								{'s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s'}};
881
			for (int tyy=0;tyy<20;tyy++){
882
				for (int txx=0;txx<20;txx++){
883
 
884
					if (tmparea[txx][tyy]=='k'){
885
						kosilkax=tyy;
886
						kosilkay=txx;
887
					}
888
 
889
					gamearea[txx][tyy]=tmparea[tyy][txx];
890
				}
891
			}
892
		}
893
 
894
 
895
			if (levnum==7){
896
		static char tmparea[20][20]={{'s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s'},
897
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','t','t','s'},
898
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','t','t','s'},
899
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','t','t','s'},
900
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','t','t','s'},
901
								{'s','g','g','g','g','g','t','t','t','t','t','t','g','g','g','g','s','t','t','s'},
902
								{'s','g','g','g','g','g','t','k','g','g','g','t','g','g','g','g','s','t','t','s'},
903
								{'s','g','g','g','g','g','t','g','g','g','g','t','g','g','g','g','s','t','t','s'},
904
								{'s','g','g','g','g','g','t','g','g','g','g','t','g','g','g','g','s','t','t','s'},
905
								{'s','g','g','g','g','g','t','g','g','g','g','t','g','g','g','g','s','s','s','s'},
906
								{'s','g','g','g','g','g','t','g','g','g','g','t','g','g','g','g','g','g','g','s'},
907
								{'s','g','g','g','g','g','t','t','t','t','g','t','g','g','g','g','g','g','g','s'},
908
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
909
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
910
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
911
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
912
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
913
								{'s','g','g','g','g','g','g','g','g','t','g','g','t','g','g','g','g','g','g','s'},
914
								{'s','g','g','g','g','g','g','g','g','t','g','g','t','g','g','g','g','g','g','s'},
915
								{'s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s'}};
916
			for (int tyy=0;tyy<20;tyy++){
917
				for (int txx=0;txx<20;txx++){
918
 
919
					if (tmparea[txx][tyy]=='k'){
920
						kosilkax=tyy;
921
						kosilkay=txx;
922
					}
923
 
924
					gamearea[txx][tyy]=tmparea[tyy][txx];
925
				}
926
			}
927
		}
928
		}
929
		else
930
		{
931
			//ВНЕШНИЕ УРОВНИ
932
			kosilkadirection=1;
933
 
934
			int currentrow=0;
935
			int currentcol=0;
936
 
937
			for (int tmpcntr=0;tmpcntr<400;tmpcntr++){
938
 
939
				currentcol=(int)(tmpcntr/20);
940
				currentrow=tmpcntr-(((int)(tmpcntr/20))*20);
941
				switch(externallevels[tmpcntr+(400*(levnum-1))]){
942
 
943
				case 0:
944
					gamearea[currentrow][currentcol]='n';
945
					break;
946
				case 1:
947
					gamearea[currentrow][currentcol]='g';
948
					break;
949
				case 2:
950
					gamearea[currentrow][currentcol]='k';
951
					kosilkax=currentrow;
952
					kosilkay=currentcol;
953
					break;
954
				case 3:
955
					gamearea[currentrow][currentcol]='s';
956
					break;
957
				case 4:
958
					gamearea[currentrow][currentcol]='t';
959
					break;
960
 
961
				}
962
			}
963
 
964
 
965
		}
966
 
967
	draw_window();
968
 
969
}
970
 
971
//Преоверяем остаток травы
972
int grassLeft(){
973
	int leftgrass=0;
974
	for (int chky=0;chky<20;chky++){
975
		for (int chkx=0;chkx<20;chkx++){
976
			if (gamearea[chkx][chky]=='g') {
977
				leftgrass++;
978
			}
979
		}
980
	}
981
	return leftgrass;
982
}
983
 
984
 
985
//Меняем уровень или выводим сообщение о том, что все уровни пройдены
986
void updateStatus(){
987
 
988
 
989
	if (grassLeft()==0) {
990
		if (level==levelcount){
991
			gamestarted=false;
992
			status=2;
993
			draw_window();
994
		} else {
995
			gamestarted=false;
996
			interlevelpause();
997
			level++;
998
			initializeLevel(level);
999
			gamestarted=true;
1000
		}
1001
	}
1002
 
1003
}
1004
 
1005
 
1006
 
1007
 
1008
void decode_skin(){
1009
	int currentbyte3x=0;
1010
	RGB tmpRGB;
1011
	int tmpcc1=0;
1012
 
1013
	for (tmpcc1=0;tmpcc1<576;tmpcc1++){
1014
 
1015
		tmpRGB.r= skindata[currentbyte3x];
1016
		tmpRGB.g= skindata[currentbyte3x+1];
1017
		tmpRGB.b= skindata[currentbyte3x+2];
1018
		kosilka_d[tmpcc1]=tmpRGB;
1019
		currentbyte3x+=3;
1020
	}
1021
 
1022
	for (tmpcc1=0;tmpcc1<576;tmpcc1++){
1023
 
1024
		tmpRGB.r= skindata[currentbyte3x];
1025
		tmpRGB.g= skindata[currentbyte3x+1];
1026
		tmpRGB.b= skindata[currentbyte3x+2];
1027
		kosilka_u[tmpcc1]=tmpRGB;
1028
		currentbyte3x+=3;
1029
	}
1030
 
1031
	for (tmpcc1=0;tmpcc1<576;tmpcc1++){
1032
 
1033
		tmpRGB.r= skindata[currentbyte3x];
1034
		tmpRGB.g= skindata[currentbyte3x+1];
1035
		tmpRGB.b= skindata[currentbyte3x+2];
1036
		kosilka_l[tmpcc1]=tmpRGB;
1037
		currentbyte3x+=3;
1038
	}
1039
 
1040
	for (tmpcc1=0;tmpcc1<576;tmpcc1++){
1041
 
1042
		tmpRGB.r= skindata[currentbyte3x];
1043
		tmpRGB.g= skindata[currentbyte3x+1];
1044
		tmpRGB.b= skindata[currentbyte3x+2];
1045
		kosilka_r[tmpcc1]=tmpRGB;
1046
		currentbyte3x+=3;
1047
	}
1048
 
1049
	for (tmpcc1=0;tmpcc1<576;tmpcc1++){
1050
 
1051
		tmpRGB.r= skindata[currentbyte3x];
1052
		tmpRGB.g= skindata[currentbyte3x+1];
1053
		tmpRGB.b= skindata[currentbyte3x+2];
1054
		skos[tmpcc1]=tmpRGB;
1055
		currentbyte3x+=3;
1056
	}
1057
 
1058
	for (tmpcc1=0;tmpcc1<576;tmpcc1++){
1059
 
1060
		tmpRGB.r= skindata[currentbyte3x];
1061
		tmpRGB.g= skindata[currentbyte3x+1];
1062
		tmpRGB.b= skindata[currentbyte3x+2];
1063
		grass[tmpcc1]=tmpRGB;
1064
		currentbyte3x+=3;
1065
	}
1066
 
1067
	for (tmpcc1=0;tmpcc1<576;tmpcc1++){
1068
 
1069
		tmpRGB.r= skindata[currentbyte3x];
1070
		tmpRGB.g= skindata[currentbyte3x+1];
1071
		tmpRGB.b= skindata[currentbyte3x+2];
1072
		stone[tmpcc1]=tmpRGB;
1073
		currentbyte3x+=3;
1074
	}
1075
 
1076
	for (tmpcc1=0;tmpcc1<576;tmpcc1++){
1077
 
1078
		tmpRGB.r= skindata[currentbyte3x];
1079
		tmpRGB.g= skindata[currentbyte3x+1];
1080
		tmpRGB.b= skindata[currentbyte3x+2];
1081
		tree[tmpcc1]=tmpRGB;
1082
		currentbyte3x+=3;
1083
	}
1084
 
1085
}
1086
 
1087
 
1088
 
1089
void load_external_levels(){
1090
 
1091
	CKosFile lev(getLevelsPathName());
1092
 
1093
level_read_result=lev.Read (external_levels_count,1);
1094
 
1095
		if (level_read_result == 1){
1096
				external_levels_available=true;
1097
		}
1098
		else
1099
		{
1100
				external_levels_available=false;
1101
		};
1102
 
1103
 
1104
		if (external_levels_count[0]==0){
1105
			external_levels_available=false;
1106
		}
1107
		else
1108
		{
1109
			externallevels = new Byte[400*external_levels_count[0]];
1110
			lev.Read (externallevels,400*external_levels_count[0]);
1111
		}
1112
 
1113
 
1114
 
1115
}
1116
 
1117
void app_halt(){
1118
 
1119
	delete apppath;
1120
	delete levpath;
1121
	if (external_levels_available==true) {delete externallevels;}
1122
	kos_ExitApp();
1123
 
1124
}
1125
 
1126
void kos_Main(){
1127
 
1128
 
1129
	load_external_levels();
1130
 
1131
	CKosFile  skin(getSkinPathName());
1132
 
1133
		read_result=skin.Read (skindata,13824);
1134
		if (read_result != 13824){
1135
			skin_available=false;
1136
		}
1137
		else
1138
		{
1139
			skin_available=true;
1140
		};
1141
 
1142
		if (skin_available==false){
1143
			decode_graphics(kosilka_d1,kosilka_d);
1144
			decode_graphics(kosilka_u1,kosilka_u);
1145
			decode_graphics(kosilka_l1,kosilka_l);
1146
			decode_graphics(kosilka_r1,kosilka_r);
1147
			decode_graphics(skos1,skos);
1148
			decode_graphics(stone1,stone);
1149
			decode_graphics(tree1,tree);
1150
			decode_graphics(grass1,grass);
1151
			skinned=false;
1152
		}
1153
		else
1154
		{
1155
			decode_skin();
1156
			skinned=true;
1157
		}
1158
 
1159
	draw_window();
1160
 
1161
	for (;;){
1162
 
1163
		switch (kos_WaitForEvent()){
1164
		case 1:
1165
			w_redraw=true;
1166
			draw_window();
1167
			break;
1168
		case 2:
1169
			Byte keyCode;
1170
			kos_GetKey(keyCode);
1171
			if (status==1){
1172
			if (gamestarted==true){
1173
				switch (keyCode){
1174
				case 177:
1175
					if (kosilkay<19){
1176
						if (gamearea[kosilkax][kosilkay+1]=='g'){
1177
							gamearea[kosilkax][kosilkay]='n';
1178
							gamearea[kosilkax][kosilkay+1]='k';
1179
 
1180
							if (drawanimation==true) {animate(kosilkax,kosilkay,1);}
1181
 
1182
 
1183
							lastkosilkadirection=kosilkadirection;
1184
							laststep=1;
1185
 
1186
							kosilkay++;
1187
							kosilkadirection=1;
1188
							draw_element(kosilkax,kosilkay);
1189
							draw_element(kosilkax,kosilkay-1);
1190
							display_grass_left();
1191
							updateStatus();
1192
						}
1193
					}
1194
					break;
1195
				case 178:
1196
					if (kosilkay>0){
1197
						if (gamearea[kosilkax][kosilkay-1]=='g'){
1198
							gamearea[kosilkax][kosilkay]='n';
1199
							gamearea[kosilkax][kosilkay-1]='k';
1200
 
1201
							if (drawanimation==true) {animate(kosilkax,kosilkay,2);}
1202
 
1203
							lastkosilkadirection=kosilkadirection;
1204
							laststep=2;
1205
 
1206
							kosilkay--;
1207
							kosilkadirection=2;
1208
 
1209
							draw_element(kosilkax,kosilkay);
1210
							draw_element(kosilkax,kosilkay+1);
1211
							display_grass_left();
1212
							updateStatus();
1213
						}
1214
					}
1215
					break;
1216
 
1217
				case 179:
1218
					if (kosilkax<19){
1219
						if (gamearea[kosilkax+1][kosilkay]=='g'){
1220
							gamearea[kosilkax][kosilkay]='n';
1221
							gamearea[kosilkax+1][kosilkay]='k';
1222
 
1223
							if (drawanimation==true) {animate(kosilkax,kosilkay,3);}
1224
 
1225
 
1226
							lastkosilkadirection=kosilkadirection;
1227
							laststep=3;
1228
 
1229
							kosilkax++;
1230
							kosilkadirection=4;
1231
 
1232
							draw_element(kosilkax,kosilkay);
1233
							draw_element(kosilkax-1,kosilkay);
1234
							display_grass_left();
1235
							updateStatus();
1236
						}
1237
					}
1238
					break;
1239
 
1240
				case 176:
1241
					if (kosilkax>0){
1242
						if (gamearea[kosilkax-1][kosilkay]=='g'){
1243
							gamearea[kosilkax][kosilkay]='n';
1244
							gamearea[kosilkax-1][kosilkay]='k';
1245
 
1246
							if (drawanimation==true) {animate(kosilkax,kosilkay,4);}
1247
 
1248
							lastkosilkadirection=kosilkadirection;
1249
							laststep=4;
1250
 
1251
							kosilkax--;
1252
							kosilkadirection=3;
1253
 
1254
							draw_element(kosilkax,kosilkay);
1255
							draw_element(kosilkax+1,kosilkay);
1256
							display_grass_left();
1257
							updateStatus();
1258
						}
1259
					}
1260
					break;
1261
 
1262
				case 27:
1263
					if (lives>0){
1264
						lives--;
1265
						initializeLevel(level);
1266
 
1267
					} else {
1268
						gamestarted=false;
1269
						status=3;
1270
						draw_window();
1271
					}
1272
					break;
1273
 
1274
				case 8:
1275
					if (laststep!=0){
1276
						kosilkadirection=lastkosilkadirection;
1277
						if (laststep==1){
1278
							gamearea[kosilkax][kosilkay]='g';
1279
							gamearea[kosilkax][kosilkay-1]='k';
1280
							draw_element(kosilkax,kosilkay);
1281
							draw_element(kosilkax,kosilkay-1);
1282
							kosilkay--;
1283
						}
1284
					if (laststep==2){
1285
							gamearea[kosilkax][kosilkay]='g';
1286
							gamearea[kosilkax][kosilkay+1]='k';
1287
							draw_element(kosilkax,kosilkay);
1288
							draw_element(kosilkax,kosilkay+1);
1289
							kosilkay++;
1290
						}
1291
 
1292
					if (laststep==3){
1293
							gamearea[kosilkax][kosilkay]='g';
1294
							gamearea[kosilkax-1][kosilkay]='k';
1295
							draw_element(kosilkax,kosilkay);
1296
							draw_element(kosilkax-1,kosilkay);
1297
							kosilkax--;
1298
						}
1299
 
1300
					if (laststep==4){
1301
							gamearea[kosilkax][kosilkay]='g';
1302
							gamearea[kosilkax+1][kosilkay]='k';
1303
							draw_element(kosilkax,kosilkay);
1304
							draw_element(kosilkax+1,kosilkay);
1305
							kosilkax++;
1306
						}
1307
 
1308
 
1309
						laststep=0;
1310
					}
1311
					break;
1312
 
1313
				}
1314
 
1315
			}
1316
			}
1317
			if (status==0){
1318
				if (keyCode==13){ //enter
1319
					if (external_levels_available==true){
1320
						status=4;
1321
						draw_window();
1322
					}
1323
					else
1324
					{
1325
						status=1;
1326
						initializeLevel(1);
1327
						gamestarted=true;
1328
					}
1329
 
1330
				}
1331
 
1332
				if (keyCode==103){
1333
					if (drawgraphics==true){
1334
						drawgraphics=false;
1335
					} else {
1336
						drawgraphics=true;
1337
					}
1338
 
1339
					if (drawgraphics==true){
1340
						kos_PutImage((RGB*)kosilka_d,24,24,305,150);
1341
					}
1342
					else
1343
					{
1344
					kos_DrawBar(305,150,24,24,0x00AAAA);
1345
					}
1346
				}
1347
 
1348
				if (keyCode==97){
1349
					if (drawanimation==true){
1350
						drawanimation=false;
1351
					} else {
1352
						drawanimation=true;
1353
					}
1354
 
1355
					if (drawanimation==true){
1356
						kos_DrawBar(335,150,24,24,0x00AA00);
1357
					}
1358
					else
1359
					{
1360
						kos_DrawBar(335,150,24,24,0xAA0000);
1361
					}
1362
				}
1363
				if (keyCode==104){
1364
						status=-1;
1365
						draw_window();
1366
				}
1367
 
1368
				if (keyCode==115){
1369
 
1370
					if (skin_available==true){
1371
					if (skinned==true){
1372
						skinned=false;
1373
						decode_graphics(kosilka_d1,kosilka_d);
1374
						decode_graphics(kosilka_u1,kosilka_u);
1375
						decode_graphics(kosilka_l1,kosilka_l);
1376
						decode_graphics(kosilka_r1,kosilka_r);
1377
						decode_graphics(skos1,skos);
1378
						decode_graphics(stone1,stone);
1379
						decode_graphics(tree1,tree);
1380
						decode_graphics(grass1,grass);
1381
					} else {
1382
						skinned=true;
1383
						decode_skin();
1384
					}
1385
 
1386
					draw_window();
1387
 
1388
					}
1389
 
1390
				}
1391
				if (keyCode==27){
1392
					app_halt();
1393
				}
1394
 
1395
			}
1396
 
1397
			if (status==4){
1398
				if (keyCode==49){ //1
1399
						external_levels=false;
1400
						status=1;
1401
						initializeLevel(1);
1402
						gamestarted=true;
1403
 
1404
				}
1405
 
1406
				if (keyCode==50){ //2
1407
						external_levels=true;
1408
						levelcount=external_levels_count[0];
1409
						status=1;
1410
						initializeLevel(1);
1411
						gamestarted=true;
1412
 
1413
				}
1414
			}
1415
 
1416
			if (status==2){
1417
				if (keyCode==113){
1418
						lives=2;
1419
						status=0;
1420
						level=1;
1421
						draw_window();
1422
						gamestarted=true;
1423
				}
1424
			}
1425
 
1426
			if (status==3){
1427
				if (keyCode==113){
1428
						lives=2;
1429
						status=0;
1430
						level=1;
1431
						draw_window();
1432
						gamestarted=true;
1433
 
1434
				}
1435
				if (keyCode==114){
1436
						lives=2;
1437
						status=1;
1438
						level=1;
1439
						initializeLevel(1);
1440
						gamestarted=true;
1441
				}
1442
 
1443
			}
1444
 
1445
			if (status==-1){
1446
				if (keyCode==8){
1447
					status=0;
1448
					draw_window();
1449
				}
1450
			}
1451
 
1452
			//Выводим код нажатой клавиши. Фича временная
1453
	/*		kos_DrawBar(20,250,150,10,0xEEEEEE);
1454
			kos_WriteTextToWindow(20,250,0x80, 0 ,"Button",0);
1455
			kos_DisplayNumberToWindow(keyCode,3,70,250,0x0000FF,nbDecimal,false);  */
1456
			break;
1457
		case 3:
1458
 
1459
			app_halt();
1460
			break;
1461
		}
1462
	}
1463
}
1464
 
1465
// Конец исходника ;-)