Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
7332 leency 1
/*	------- KOSILKA FOR KOLIBI -------
2
Written in C++ (MS Visual C++ 6.0+).
3
Version 1.16.
968 leency 4
 
5
					 Andrey Mihaylovich aka Dron2004
3132 leency 6
*/
968 leency 7
 
8
 
9
#include "kosSyst.h"
10
#include "kosFile.h"
3132 leency 11
#include "images.cpp"
968 leency 12
 
13
 
7332 leency 14
//External levels
968 leency 15
bool external_levels_available=false;
16
bool external_levels = false;
17
int level_read_result;
18
Byte * externallevels;
19
Byte external_levels_count[1] = {0};
20
/////////////////
21
 
22
int lastkosilkadirection=1;
7332 leency 23
int laststep=0; //Last step. 0-does not exists, 1-bottom, 2-up, 3-left, 4-right
968 leency 24
 
25
 
26
Byte skindata[13824];
27
int read_result=0;
28
bool skin_available=false;
29
bool w_redraw=true;
30
 
7341 leency 31
#define RUS 1
32
#define ENG 2
33
#ifndef LANG
34
#define LANG RUS
35
#endif
36
 
37
#if LANG == RUS
7332 leency 38
	const char windowTitle[] = "Косилка для Колибри";
39
	const char version[]     = "Версия 1.16";
40
	const char win[]         = "Вы выиграли!";
41
	const char press_q[]     = "<нажмите  для возврата в меню>";
42
	const char fail[]        = "Игра окончена...";
43
	const char press_r[]     = "<нажмите  для того, чтобы сыграть ещё раз>";
44
	const char k_o_s_i_l_k[] = "К   О   С   И   Л   К   А";
7345 leency 45
	const char k_o_s_i_l_2[] = "К  О  С  И  Л  К  А";
7332 leency 46
	const char for_kolibri[] = "для Колибри ОС";
47
	const char press_enter[] = "<для начала игры нажмите ENTER>";
48
	const char press_g[]     = "<нажмите  для переключения режима графики>";
49
	const char press_a[]     = "<нажмите  для включения/выключения анимации>";
50
	const char press_h[]     = "<нажмите  для просмотра сведений о программе>";
51
	const char press_s[]     = "<нажмите  чтобы выключить/включить скин>";
7333 leency 52
	const char level_label[] = "Уровень:";
7332 leency 53
	const char attempts_left[] = "Осталось попыток:";
54
	const char grass_left[]  = "Осталось травы:";
7344 leency 55
 
56
	const char level_select_1[] = "Выберите набор уровней (нажмите <1> или <2>):";
57
	const char level_select_2[] = "1. Встроенные уровни";
58
	const char level_select_3[] = "2. Внешний набор уровней";
59
 
60
	const char about1[] = "Коллектив разработчиков:";
61
	const char about2[] = "Андрей Михайлович aka Dron2004 - программирование, встроенная графика (без скина)";
62
	const char about3[] = "Mario79 - тестирование, помощь в разработке, важные идеи";
63
	const char about4[] = "Ataualpa - тестирование, помощь в разработке";
64
	const char about5[] = "Leency - тестирование, помощь в разработке, замечательные скины, важные идеи";
65
	const char about6[] = "Mike - тестирование, помощь в разработке";
66
	const char about7[] = "bw - тестирование, помощь в разработке, важные идеи";
67
	const char about8[] = "diamond - идея отмены хода, тестирование";
68
	const char about9[] = "Отдельное спасибо:";
69
	const char about10[] = "Всем, кто играет в эту игру :-) !";
70
	const char about11[] = "нажмите  для возврата в меню";
7332 leency 71
#else
72
	const char windowTitle[] = "Kosilka for Kolibri";
73
	const char version[]     = "  Ver. 1.16";
74
	const char win[]         = "  You won!  ";
75
	const char press_q[]     = " to return to the menu>";
76
	const char fail[]        = "   Game over.   ";
77
	const char press_r[]     = "";
78
	const char k_o_s_i_l_k[] = "K   O   S   I   L   K   A";
7345 leency 79
	const char k_o_s_i_l_2[] = "K  O  S  I  L  K  A";
7332 leency 80
	const char for_kolibri[] = "for Kolibri OS";
81
	const char press_enter[] = "press ENTER to start the game";
82
	const char press_g[]     = " to switch graphics mode>";
83
	const char press_a[]     = " to turn on/off animation>";
84
	const char press_h[]     = " to view information about the program>";
85
	const char press_s[]     = " to turn on/off external skin>";
7333 leency 86
	const char level_label[] = "Level:";
7332 leency 87
	const char attempts_left[] = "Attempts left:";
88
	const char grass_left[]  = "Grass left:";
7344 leency 89
 
90
	const char level_select_1[] = "Shoose level pack (press <1> or <2>):";
91
	const char level_select_2[] = "1. Built-in levels";
92
	const char level_select_3[] = "2. External levels";
93
 
94
	const char about1[] = "Our team:";
95
	const char about2[] = "Andrei Mikhailovich aka Dron2004 - development, built-in graphics (excluding skin)";
96
	const char about5[] = "Leency - help in development and bugfixing, English translation, testing, beautiful skins";
97
	const char about3[] = "Mario79 - testing, help in development, ideas";
98
	const char about4[] = "Ataualpa - testing, help in development";
99
	const char about6[] = "Mike - testing, help in development";
100
	const char about7[] = "bw - testing, help in development, ideas";
101
	const char about8[] = "diamond - idea of turn back, testing";
102
	const char about9[] = "Special thanks to:";
103
	const char about10[] = "Everyone who plays this game :-) !";
104
	const char about11[] = "press  to back to menu";
7332 leency 105
#endif
968 leency 106
 
7332 leency 107
int levelcount=7;
968 leency 108
 
7332 leency 109
char gamearea[20][20]; //The map
968 leency 110
 
7332 leency 111
 
112
short int kosilkax; // Kosilka position
968 leency 113
short int kosilkay;
7332 leency 114
short int kosilkadirection=1; //Last step direction. 1-bottom, 2-up, 3-left, 4-right
115
short int lives=2;
116
short int level=1;
117
short int status=0; //Where 0 - welcome screen
118
					// 1 - the game
119
					// 2 - win
120
					// 3 - fail
121
					// 4 - select the level (internal or external)
122
					// -1 - about
123
bool gamestarted=false; //Key locker. If "false" then not possible to play
968 leency 124
 
7332 leency 125
bool drawgraphics=true; //Draw detailed graphics or just colored rectangles
126
bool drawanimation=true;
127
int grassLeft();  //Notify about "Grass Left" function
968 leency 128
 
129
RGB kosilka_d[576];
130
RGB kosilka_l[576];
131
RGB kosilka_r[576];
132
RGB kosilka_u[576];
133
RGB grass[576];
134
RGB stone[576];
135
RGB tree[576];
136
RGB skos[576];
137
 
7332 leency 138
//Palette. Decoding to 0xRRGGBB
968 leency 139
char * apppath;
140
char * levpath;
141
 
142
 
143
char * getLevelsPathName(){
144
 
145
	int lastslashindex=0;
146
	static char levfilename[]="koslevel.pak";
147
	int tempslfnd=0;
148
 
149
	for (tempslfnd=0; tempslfnd < strlen(kosExePath); tempslfnd++){
150
			if (kosExePath[tempslfnd]=='/'){lastslashindex=tempslfnd;}
151
	}
152
 
153
	levpath = new char[lastslashindex+strlen(levfilename)+1];
154
 
155
	for (tempslfnd=0; tempslfnd <= lastslashindex; tempslfnd++){
156
		levpath[tempslfnd]=kosExePath[tempslfnd];
157
	}
158
	for (tempslfnd=0; tempslfnd < strlen(levfilename); tempslfnd++){
159
		levpath[tempslfnd+lastslashindex+1]=levfilename[tempslfnd];
160
	}
161
 
162
	return levpath;
163
}
164
 
165
 
7332 leency 166
void interlevelpause(){ //The pause between levels
968 leency 167
	Byte tempCode;
168
	RGB tmprgb;
169
	int tmpa=0;
170
	laststep=0;
171
	static int yellow_pal[] = {0xA8A93D,0xBEBF4C,0xD6D856,0xDFE15A,0xECEE5B,
172
						    0xECEE5B,0xDFE15A,0xD6D856,0xBEBF4C,0xA8A93D};
173
		for (int iic=0;iic<240;iic++){
3137 leency 174
			kos_WaitForEvent(1); //Pause()?
968 leency 175
			kos_GetKey(tempCode);
176
 
177
			kos_DrawBar(iic*2,0,2,480,yellow_pal[tmpa]);
178
 
179
			tmpa++;
3132 leency 180
			if (tmpa>9) tmpa=0;
968 leency 181
		}
182
}
183
 
7332 leency 184
void draw_element(int elx, int ely){ //Draw map element
968 leency 185
switch (gamearea[elx][ely]){
186
			case 'g':
187
				if (drawgraphics==true){
188
					kos_PutImage((RGB*)grass,24,24,elx*24,ely*24);
189
				}
190
				else
191
				{
192
					kos_DrawBar(elx*24,ely*24,24,24,0xAAAA00);
193
				}
194
 
195
				break;
196
			case 'k':
197
				if (drawgraphics==true){
198
					switch(kosilkadirection){
199
					case 1:
200
						kos_PutImage((RGB*)kosilka_d,24,24,elx*24,ely*24);
201
						break;
202
					case 2:
203
						kos_PutImage((RGB*)kosilka_u,24,24,elx*24,ely*24);
204
						break;
205
					case 3:
206
						kos_PutImage((RGB*)kosilka_l,24,24,elx*24,ely*24);
207
						break;
208
					case 4:
209
						kos_PutImage((RGB*)kosilka_r,24,24,elx*24,ely*24);
210
						break;
211
					}
212
				}
213
				else
214
				{
215
					kos_DrawBar(elx*24,ely*24,24,24,0x00AAAA);
216
				}
217
 
218
 
219
				break;
220
			case 'n':
221
				if (drawgraphics==true){
222
					kos_PutImage((RGB*)skos,24,24,elx*24,ely*24);
223
				}
224
				else
225
				{
226
					kos_DrawBar(elx*24,ely*24,24,24,0xAAAAAA);
227
				}
228
 
229
 
230
				break;
231
			case 's':
232
				if (drawgraphics==true){
233
					kos_PutImage((RGB*)stone,24,24,elx*24,ely*24);
234
				}
235
				else
236
				{
237
					kos_DrawBar(elx*24,ely*24,24,24,0x555555);
238
				}
239
 
240
 
241
				break;
242
 
243
			case 't':
244
				if (drawgraphics==true){
245
					kos_PutImage((RGB*)tree,24,24,elx*24,ely*24);
246
				}
247
				else
248
				{
249
					kos_DrawBar(elx*24,ely*24,24,24,0x005500);
250
				}
251
 
252
 
253
				break;
254
			}
255
 
256
}
257
 
258
 
7332 leency 259
void display_grass_left(){
968 leency 260
	kos_DrawBar(605,120,20,10,0xEEEEEE);
261
	kos_DisplayNumberToWindow(grassLeft(),3,605,120,0x0000FF,nbDecimal,false);
262
}
263
 
264
 
7332 leency 265
void animate(int initcellx, int initcelly, int direction){ //kosilka movement animation
968 leency 266
	int tmpp=0;
267
 
3132 leency 268
	switch (direction){
968 leency 269
		case 1:
270
			for (tmpp=0; tmpp<23;tmpp++){
271
				if (drawgraphics==true){
272
					kos_PutImage((RGB*)skos,24,24,initcellx*24,initcelly*24);
273
					kos_PutImage((RGB*)kosilka_d,24,24,initcellx*24,initcelly*24+tmpp);
274
				} else {
275
					kos_DrawBar(initcellx*24,initcelly*24,24,24,0xAAAAAA);
276
					kos_DrawBar(initcellx*24,initcelly*24+tmpp,24,24,0x00AAAA);
277
 
278
				}
279
				kos_Pause(1);
280
			}
281
			break;
282
		case 2:
283
			for (tmpp=0; tmpp<23;tmpp++){
284
				if (drawgraphics==true){
285
					kos_PutImage((RGB*)skos,24,24,initcellx*24,initcelly*24);
286
					kos_PutImage((RGB*)kosilka_u,24,24,initcellx*24,initcelly*24-tmpp);
287
				} else {
288
					kos_DrawBar(initcellx*24,initcelly*24,24,24,0xAAAAAA);
289
					kos_DrawBar(initcellx*24,initcelly*24-tmpp,24,24,0x00AAAA);
290
				}
291
				kos_Pause(1);
292
			}
293
			break;
294
		case 3:
295
			for (tmpp=0; tmpp<23;tmpp++){
296
				if (drawgraphics==true){
297
					kos_PutImage((RGB*)skos,24,24,initcellx*24,initcelly*24);
298
					kos_PutImage((RGB*)kosilka_r,24,24,initcellx*24+tmpp,initcelly*24);
299
				} else {
300
					kos_DrawBar(initcellx*24,initcelly*24,24,24,0xAAAAAA);
301
					kos_DrawBar(initcellx*24+tmpp,initcelly*24,24,24,0x00AAAA);
302
 
303
				}
304
				kos_Pause(1);
305
			}
306
			break;
307
		case 4:
308
			for (tmpp=0; tmpp<23;tmpp++){
309
				if (drawgraphics==true){
310
					kos_PutImage((RGB*)skos,24,24,initcellx*24,initcelly*24);
311
					kos_PutImage((RGB*)kosilka_l,24,24,initcellx*24-tmpp,initcelly*24);
312
				} else {
313
					kos_DrawBar(initcellx*24,initcelly*24,24,24,0xAAAAAA);
314
					kos_DrawBar(initcellx*24-tmpp,initcelly*24,24,24,0x00AAAA);
315
 
316
				}
317
				kos_Pause(1);
318
			}
319
			break;
3132 leency 320
	}
968 leency 321
}
322
 
323
 
7332 leency 324
void draw_window(void){
2131 leency 325
	sProcessInfo sPI;
326
 
968 leency 327
	if (w_redraw)
328
	{
7332 leency 329
		kos_WindowRedrawStatus(1);
3132 leency 330
		kos_DefineAndDrawWindow(50,50,640,506-22+kos_GetSkinHeight(),0x74,0xEEEEEE,0,0,(Dword)windowTitle);
7332 leency 331
		kos_WindowRedrawStatus(2);
968 leency 332
	}
333
	w_redraw=false;
334
 
2131 leency 335
	kos_ProcessInfo( &sPI );
7332 leency 336
	if (sPI.rawData[70]&0x04) return; //do nothing if window is rolled-up into title
968 leency 337
 
7332 leency 338
	//Map redraw
968 leency 339
	if ((status!=0)&&(status!=-1)&&(status!=4))
340
	{
341
		kos_DrawBar(631-151,0,151,480,0xEEEEEE);
342
 
7345 leency 343
		kos_WriteTextToWindow(500,30,0x80, 0, (char*)k_o_s_i_l_2,19);
7332 leency 344
		kos_WriteTextToWindow(517,40,0x80, 0, (char*)for_kolibri,14);
968 leency 345
 
7333 leency 346
		kos_WriteTextToWindow(495,80,0x80, 0, (char*)level_label,6);
968 leency 347
		kos_DisplayNumberToWindow(level,3,605,80,0x0000FF,nbDecimal,false);
348
 
7332 leency 349
		kos_WriteTextToWindow(495,95,0x80, 0, (char*)attempts_left,11);
968 leency 350
		kos_DisplayNumberToWindow(lives,1,605,95,0x0000FF,nbDecimal,false);
351
 
7332 leency 352
		kos_WriteTextToWindow(495,120,0x80, 0, (char*)grass_left,11);
968 leency 353
		display_grass_left();
354
 
7332 leency 355
		kos_WriteTextToWindow(526,450,0x80, 0,(char*)version,12);
968 leency 356
 
357
		for (int cy=0;cy<20;cy++) for (int cx=0;cx<20;cx++)	draw_element(cx,cy);
358
	}
359
 
360
	if (status==0){
361
		kos_DrawBar(0,0,4,480,0x000000);
362
		kos_DrawBar(628,0,3,480,0x000000);
7332 leency 363
 
968 leency 364
 
365
		for (int tmpppy=0;tmpppy<20;tmpppy++){
366
			for (int tmpppx=0;tmpppx<26;tmpppx++){
367
				if ((tmpppx==0) || (tmpppx==25) || (tmpppy==0) || (tmpppy==19)){
368
					kos_PutImage((RGB*)stone,24,24,4+tmpppx*24,tmpppy*24);
369
				}
370
				else
371
				{
372
					kos_PutImage((RGB*)skos,24,24,4+tmpppx*24,tmpppy*24);
373
				}
374
			}
375
		}
376
 
377
		if (drawgraphics==true){
378
			kos_PutImage((RGB*)kosilka_d,24,24,305,150);
379
		}
380
		else
381
		{
382
			kos_DrawBar(305,150,24,24,0x00AAAA);
383
		}
384
 
385
 
386
		if (drawanimation==true){
387
			kos_DrawBar(335,150,24,24,0x00AA00);
388
		}
389
		else
390
		{
391
			kos_DrawBar(335,150,24,24,0xAA0000);
392
		}
393
 
7332 leency 394
                kos_WriteTextToWindow(255, 200,0x80, 0xFFFFFF, (char*)k_o_s_i_l_k, 19);
395
                kos_WriteTextToWindow(290, 220,0x80, 0xFFFFFF, (char*)for_kolibri, 14);
396
                kos_WriteTextToWindow(239, 240,0x80, 0xFFFFFF, (char*)press_enter, 30);
397
                kos_WriteTextToWindow(30,  380,0x80, 0xFFFFFF, (char*)press_g, 53);
398
                kos_WriteTextToWindow(30,  400,0x80, 0xFFFFFF, (char*)press_a, 41);
399
                kos_WriteTextToWindow(30,  420,0x80, 0xFFFFFF, (char*)press_h, 32);
400
                if (skin_available==true) kos_WriteTextToWindow(30, 440,0x80, 0xFFFFFF, (char*)press_s, 27);
968 leency 401
 
402
        //      kos_WriteTextToWindow(470, 440,0x80, 0xFFFFFF ,"нажмите  для выхода",27);
403
	//	kos_DisplayNumberToWindow(external_levels_count[0],3,200,340,0x0000FF,nbDecimal,false);
404
 
405
 
406
 
1012 leency 407
		kos_WriteTextToWindow(533, 440,0x80, 0xFFFFFF ,(char*)version,0);
968 leency 408
	}
409
	if (status==2){
410
	   kos_DrawBar(10,150,610,200,0x528B4C);
411
	   kos_DrawBar(15,155,601,190,0x3BCF46);
7332 leency 412
           kos_WriteTextToWindow(240,230,0x80, 0xFFFFFF ,(char*)win,13);
413
           kos_WriteTextToWindow(240,250,0x80, 0xFFFFFF ,(char*)press_q,17);
968 leency 414
	}
415
	if (status==3){
416
	   kos_DrawBar(10,150,610,200,0x8B4C4C);
417
	   kos_DrawBar(15,155,601,190,0xCF3B3B);
7332 leency 418
           kos_WriteTextToWindow(220,220,0x80, 0xFFFFFF ,(char*)fail,13);
419
           kos_WriteTextToWindow(220,240,0x80, 0xFFFFFF ,(char*)press_r,23);
420
           kos_WriteTextToWindow(220,260,0x80, 0xFFFFFF ,(char*)press_q,17);
968 leency 421
	}
422
	if (status==-1){
423
 
424
		kos_DrawBar(0,0,4,480,0x000000);
425
		kos_DrawBar(631-3,0,3,480,0x000000);
426
 
427
	   for (int tmpppy=0;tmpppy<20;tmpppy++){
428
			for (int tmpppx=0;tmpppx<26;tmpppx++){
429
				if ((tmpppx==0) || (tmpppx==25) || (tmpppy==0) || (tmpppy==19)){
430
					kos_PutImage((RGB*)stone,24,24,4+tmpppx*24,tmpppy*24);
431
				}
432
				else
433
				{
434
					kos_PutImage((RGB*)skos,24,24,4+tmpppx*24,tmpppy*24);
435
				}
436
			}
437
		}
438
 
7344 leency 439
		kos_WriteTextToWindow(40,40,0x80, 0xFFFFFF, (char*)windowTitle,22);
440
		kos_WriteTextToWindow(40,60,0x80, 0xFFFFFF, (char*)version,12);
441
		kos_WriteTextToWindow(40,75,0x80, 0xFFFFFF, "________________________________________",40);
968 leency 442
 
7344 leency 443
		kos_WriteTextToWindow(40,120,0x80, 0xFFFFFF, (char*)about1, 18);
444
		kos_WriteTextToWindow(40,150,0x80, 0xEEFFEE, (char*)about2, 32);
445
		kos_WriteTextToWindow(40,170,0x80, 0xDDFFDD, (char*)about3, 35);
446
		kos_WriteTextToWindow(40,190,0x80, 0xCCFFCC, (char*)about4, 36);
447
		kos_WriteTextToWindow(40,210,0x80, 0xBBFFBB, (char*)about5, 62);
448
		kos_WriteTextToWindow(40,230,0x80, 0xAAFFAA, (char*)about6, 34);
449
		kos_WriteTextToWindow(40,250,0x80, 0x99FF99, (char*)about7, 49);
450
		kos_WriteTextToWindow(40,270,0x80, 0x99FF99, (char*)about8, 49);
968 leency 451
 
7344 leency 452
		kos_WriteTextToWindow(40,300,0x80, 0x88FF88, (char*)about9, 16);
453
		kos_WriteTextToWindow(40,330,0x80, 0x77FF77, (char*)about10, 50);
968 leency 454
 
7344 leency 455
		kos_WriteTextToWindow(40,430,0x80, 0x66FF66, (char*)about11, 35);
968 leency 456
	}
457
 
458
 
459
	if (status==4){
460
		kos_DrawBar(0,0,631,480,0x000000);
461
 
462
 
463
		for (int tmpppy=0;tmpppy<20;tmpppy++){
464
			for (int tmpppx=0;tmpppx<26;tmpppx++){
465
				if ((tmpppx==0) || (tmpppx==25) || (tmpppy==0) || (tmpppy==19)){
466
					kos_PutImage((RGB*)stone,24,24,4+tmpppx*24,tmpppy*24);
467
				}
468
				else
469
				{
470
					kos_PutImage((RGB*)skos,24,24,4+tmpppx*24,tmpppy*24);
471
				}
472
			}
473
		}
474
 
7344 leency 475
                kos_WriteTextToWindow(215, 200,0x80, 0xFFFFFF, (char*)level_select_1,0);
476
                kos_WriteTextToWindow(215, 220,0x80, 0xFFFFFF, (char*)level_select_2,0);
477
                kos_WriteTextToWindow(215, 240,0x80, 0xFFFFFF, (char*)level_select_3,0);
968 leency 478
 
479
	}
480
 
481
}
482
 
483
 
484
 
7332 leency 485
//Game level description,
486
//where k - kosilka
487
//		g - grass
488
//		n - cut grass
489
//		s - stone
490
//		t - tree
968 leency 491
void initializeLevel(int levnum){
492
	laststep=0;
493
	if (external_levels==false){
494
 
495
	kosilkadirection=1;
496
	if (levnum==1){
497
		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'},
498
								{'g','s','g','s','g','g','g','s','g','s','g','g','s','g','g','g','g','g','g','g'},
499
								{'g','t','g','s','g','g','g','s','g','s','g','g','s','g','g','g','g','g','g','g'},
500
								{'g','s','g','s','g','g','g','s','g','s','g','g','s','g','g','g','g','g','g','g'},
501
								{'g','t','g','s','g','g','g','s','g','s','g','g','s','g','g','g','g','g','g','g'},
502
								{'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
503
								{'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','s','s','s','g','g'},
504
								{'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','s','s','s','g','g'},
505
								{'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','s','s','s','g','g'},
506
								{'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','s','g','g','g','g'},
507
								{'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
508
								{'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
509
								{'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
510
								{'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
511
								{'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
512
								{'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
513
								{'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
514
								{'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
515
								{'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
516
								{'g','g','g','s','g','g','g','g','g','s','g','g','s','g','g','g','g','g','g','g'}};
517
			for (int tyy=0;tyy<20;tyy++){
518
				for (int txx=0;txx<20;txx++){
519
 
520
					if (tmparea[txx][tyy]=='k'){
521
						kosilkax=tyy;
522
						kosilkay=txx;
523
					}
524
 
525
					gamearea[txx][tyy]=tmparea[tyy][txx];
526
				}
527
			}
528
	}
529
	if (levnum==2){
530
		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'},
531
								{'s','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','s','g'},
532
								{'g','k','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','s','g'},
533
								{'g','g','g','g','g','g','g','g','g','g','g','g','s','s','g','g','g','g','g','g'},
534
								{'g','g','g','g','g','g','g','g','g','g','g','g','s','s','g','g','g','g','g','g'},
535
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
536
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
537
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
538
								{'s','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
539
								{'s','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
540
								{'g','g','g','g','g','g','g','g','s','s','g','g','g','g','g','g','g','s','s','g'},
541
								{'g','g','g','g','g','g','g','g','s','s','g','g','g','g','g','g','g','s','s','g'},
542
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
543
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
544
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','s','s','g','g','g','g','g'},
545
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','s','s','g','g','g','g','g'},
546
								{'g','g','g','s','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
547
								{'g','g','g','s','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
548
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
549
								{'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'}};
550
			for (int tyy=0;tyy<20;tyy++){
551
				for (int txx=0;txx<20;txx++){
552
 
553
					if (tmparea[txx][tyy]=='k'){
554
						kosilkax=tyy;
555
						kosilkay=txx;
556
					}
557
 
558
					gamearea[txx][tyy]=tmparea[tyy][txx];
559
				}
560
			}
561
	}
562
 
563
	if (levnum==3){
564
		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'},
565
								{'n','t','g','g','g','g','g','g','g','g','g','g','s','n','n','s','n','s','t','g'},
566
								{'t','n','g','g','g','g','g','g','g','g','g','g','n','t','n','n','n','t','t','g'},
567
								{'n','t','g','g','g','g','g','g','g','g','g','g','n','s','n','s','n','s','t','g'},
568
								{'t','n','g','g','g','g','g','s','s','g','g','g','n','n','n','n','n','t','t','g'},
569
								{'n','t','g','g','g','g','g','g','g','g','g','g','t','n','s','n','n','s','t','g'},
570
								{'t','n','g','g','g','g','g','g','g','g','g','g','n','n','n','n','n','t','t','g'},
571
								{'n','t','g','g','g','g','g','g','g','g','g','g','n','n','s','n','n','s','t','g'},
572
								{'t','n','g','g','g','g','g','g','g','g','g','g','n','s','n','n','n','t','t','g'},
573
								{'n','t','g','g','g','g','g','g','g','g','g','g','s','n','n','n','n','t','g','g'},
574
								{'t','n','g','g','g','s','g','g','g','g','g','g','t','t','t','t','t','t','g','g'},
575
								{'n','t','g','g','g','s','g','g','g','g','g','g','g','g','g','g','g','t','g','g'},
576
								{'t','n','g','g','g','g','g','g','g','g','g','g','t','t','g','g','g','t','g','g'},
577
								{'n','t','g','g','g','g','g','g','t','t','g','g','g','t','g','g','g','t','g','g'},
578
								{'t','n','g','g','g','g','g','g','t','t','g','g','g','t','g','g','g','t','g','g'},
579
								{'n','t','g','g','g','g','g','g','g','g','g','g','g','t','g','g','g','t','g','g'},
580
								{'t','n','g','g','g','g','g','g','g','g','g','g','g','t','t','g','g','t','g','g'},
581
								{'n','t','g','g','g','g','g','g','g','g','g','g','g','g','t','g','g','t','g','g'},
582
								{'t','n','g','g','g','g','g','g','g','g','g','g','g','g','t','g','g','t','g','g'},
583
								{'n','t','s','s','s','s','s','s','s','s','s','s','s','s','t','g','g','g','g','g'}};
584
			for (int tyy=0;tyy<20;tyy++){
585
				for (int txx=0;txx<20;txx++){
586
 
587
					if (tmparea[txx][tyy]=='k'){
588
						kosilkax=tyy;
589
						kosilkay=txx;
590
					}
591
 
592
					gamearea[txx][tyy]=tmparea[tyy][txx];
593
				}
594
			}
595
	}
596
 
597
		if (levnum==4){
598
		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'},
599
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','n','t'},
600
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','n','t'},
601
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','n','t'},
602
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','s','n','t'},
603
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','s','n','t'},
604
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','s','n','t'},
605
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','s','n','t'},
606
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','s','s','t'},
607
								{'t','g','g','g','g','t','t','t','t','t','t','t','t','g','g','g','g','g','g','t'},
608
								{'t','g','g','g','g','t','t','t','t','t','t','t','t','g','g','g','g','g','g','t'},
609
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','t'},
610
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','t'},
611
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','t'},
612
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','t'},
613
								{'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','t'},
614
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
615
								{'t','k','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
616
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
617
								{'t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t'}};
618
			for (int tyy=0;tyy<20;tyy++){
619
				for (int txx=0;txx<20;txx++){
620
 
621
					if (tmparea[txx][tyy]=='k'){
622
						kosilkax=tyy;
623
						kosilkay=txx;
624
					}
625
 
626
					gamearea[txx][tyy]=tmparea[tyy][txx];
627
				}
628
			}
629
	}
630
 
631
			if (levnum==5){
632
		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'},
633
								{'t','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
634
								{'t','t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
635
								{'t','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
636
								{'t','s','g','g','g','g','g','t','g','g','t','g','g','g','g','g','g','g','g','t'},
637
								{'t','t','g','g','g','g','t','n','t','t','t','g','g','g','g','g','g','g','g','t'},
638
								{'t','s','g','g','g','g','t','n','n','n','t','g','g','g','g','g','g','g','g','t'},
639
								{'t','k','g','g','g','g','t','n','n','n','t','g','g','g','g','g','g','g','g','t'},
640
								{'t','g','g','g','g','g','t','n','n','n','t','g','g','g','g','g','g','g','g','t'},
641
								{'t','g','g','g','g','g','t','n','n','t','g','g','g','g','g','g','g','g','g','t'},
642
								{'t','g','g','g','g','g','t','n','n','t','g','g','g','g','g','g','g','g','g','t'},
643
								{'t','g','g','g','g','g','t','n','n','n','t','g','g','g','g','g','g','g','g','t'},
644
								{'t','g','g','g','g','g','t','n','n','n','t','g','g','g','g','g','g','g','g','t'},
645
								{'t','g','g','g','g','g','g','t','n','t','t','g','g','g','g','g','g','g','g','t'},
646
								{'t','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','g','t'},
647
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
648
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
649
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
650
								{'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
651
								{'t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t'}};
652
			for (int tyy=0;tyy<20;tyy++){
653
				for (int txx=0;txx<20;txx++){
654
 
655
					if (tmparea[txx][tyy]=='k'){
656
						kosilkax=tyy;
657
						kosilkay=txx;
658
					}
659
 
660
					gamearea[txx][tyy]=tmparea[tyy][txx];
661
				}
662
			}
663
			}
664
 
665
		if (levnum==6){
666
		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'},
667
								{'s','k','t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
668
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
669
								{'s','g','g','s','s','s','s','s','s','s','s','s','s','s','s','s','s','g','g','s'},
670
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','t','t','s','g','g','s'},
671
								{'s','g','g','s','g','g','g','g','g','g','g','g','g','g','t','t','s','g','g','s'},
672
								{'s','g','g','s','g','g','g','g','g','g','g','g','g','g','t','t','s','g','g','s'},
673
								{'s','g','g','s','g','g','g','g','g','t','t','g','g','g','g','g','s','g','g','s'},
674
								{'s','g','g','s','g','g','g','g','g','t','t','t','g','g','g','g','s','g','g','s'},
675
								{'s','g','g','s','g','g','g','t','t','t','t','t','t','g','g','g','s','g','g','s'},
676
								{'s','g','g','s','g','g','g','t','t','t','t','t','t','g','g','g','s','g','g','s'},
677
								{'s','g','g','s','g','g','g','g','g','t','t','g','g','g','g','g','s','g','g','s'},
678
								{'s','g','g','s','g','g','g','g','g','t','t','g','g','g','g','g','s','g','g','s'},
679
								{'s','g','g','s','g','g','g','g','g','g','g','g','g','g','g','g','s','g','g','s'},
680
								{'s','g','g','s','g','g','g','g','g','g','g','g','g','g','g','g','s','g','g','s'},
681
								{'s','g','g','s','g','g','g','g','g','g','g','g','g','g','g','g','s','g','g','s'},
682
								{'s','g','g','s','s','s','s','s','s','s','s','s','s','s','s','s','s','g','g','s'},
683
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
684
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
685
								{'s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s'}};
686
			for (int tyy=0;tyy<20;tyy++){
687
				for (int txx=0;txx<20;txx++){
688
 
689
					if (tmparea[txx][tyy]=='k'){
690
						kosilkax=tyy;
691
						kosilkay=txx;
692
					}
693
 
694
					gamearea[txx][tyy]=tmparea[tyy][txx];
695
				}
696
			}
697
		}
698
 
699
 
700
			if (levnum==7){
701
		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'},
702
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','t','t','s'},
703
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','t','t','s'},
704
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','t','t','s'},
705
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','t','t','s'},
706
								{'s','g','g','g','g','g','t','t','t','t','t','t','g','g','g','g','s','t','t','s'},
707
								{'s','g','g','g','g','g','t','k','g','g','g','t','g','g','g','g','s','t','t','s'},
708
								{'s','g','g','g','g','g','t','g','g','g','g','t','g','g','g','g','s','t','t','s'},
709
								{'s','g','g','g','g','g','t','g','g','g','g','t','g','g','g','g','s','t','t','s'},
710
								{'s','g','g','g','g','g','t','g','g','g','g','t','g','g','g','g','s','s','s','s'},
711
								{'s','g','g','g','g','g','t','g','g','g','g','t','g','g','g','g','g','g','g','s'},
712
								{'s','g','g','g','g','g','t','t','t','t','g','t','g','g','g','g','g','g','g','s'},
713
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
714
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
715
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
716
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
717
								{'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
718
								{'s','g','g','g','g','g','g','g','g','t','g','g','t','g','g','g','g','g','g','s'},
719
								{'s','g','g','g','g','g','g','g','g','t','g','g','t','g','g','g','g','g','g','s'},
720
								{'s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s'}};
721
			for (int tyy=0;tyy<20;tyy++){
722
				for (int txx=0;txx<20;txx++){
723
 
724
					if (tmparea[txx][tyy]=='k'){
725
						kosilkax=tyy;
726
						kosilkay=txx;
727
					}
728
 
729
					gamearea[txx][tyy]=tmparea[tyy][txx];
730
				}
731
			}
732
		}
733
		}
734
		else
735
		{
7332 leency 736
			//External levels
968 leency 737
			kosilkadirection=1;
738
 
739
			int currentrow=0;
740
			int currentcol=0;
741
 
742
			for (int tmpcntr=0;tmpcntr<400;tmpcntr++){
743
 
744
				currentcol=(int)(tmpcntr/20);
745
				currentrow=tmpcntr-(((int)(tmpcntr/20))*20);
746
				switch(externallevels[tmpcntr+(400*(levnum-1))]){
747
 
748
				case 0:
749
					gamearea[currentrow][currentcol]='n';
750
					break;
751
				case 1:
752
					gamearea[currentrow][currentcol]='g';
753
					break;
754
				case 2:
755
					gamearea[currentrow][currentcol]='k';
756
					kosilkax=currentrow;
757
					kosilkay=currentcol;
758
					break;
759
				case 3:
760
					gamearea[currentrow][currentcol]='s';
761
					break;
762
				case 4:
763
					gamearea[currentrow][currentcol]='t';
764
					break;
765
 
766
				}
767
			}
768
 
769
 
770
		}
771
 
772
	draw_window();
773
 
774
}
775
 
776
int grassLeft(){
777
	int leftgrass=0;
778
	for (int chky=0;chky<20;chky++){
779
		for (int chkx=0;chkx<20;chkx++){
780
			if (gamearea[chkx][chky]=='g') {
781
				leftgrass++;
782
			}
783
		}
784
	}
785
	return leftgrass;
786
}
787
 
7332 leency 788
//Change level or show win message
968 leency 789
void updateStatus(){
790
 
791
	if (grassLeft()==0) {
792
		if (level==levelcount){
793
			gamestarted=false;
794
			status=2;
795
			draw_window();
796
		} else {
797
			gamestarted=false;
798
			interlevelpause();
799
			level++;
800
			initializeLevel(level);
801
			gamestarted=true;
802
		}
803
	}
804
 
805
}
806
 
807
 
808
void load_external_levels(){
809
 
810
	CKosFile lev(getLevelsPathName());
811
 
3132 leency 812
	level_read_result=lev.Read (external_levels_count,1);
968 leency 813
 
3132 leency 814
	if (level_read_result == 1)
815
			external_levels_available=true;
816
	else
817
			external_levels_available=false;
968 leency 818
 
3132 leency 819
	if (external_levels_count[0]==0)
968 leency 820
			external_levels_available=false;
3132 leency 821
	else
822
	{
823
		externallevels = new Byte[400*external_levels_count[0]];
824
		lev.Read (externallevels,400*external_levels_count[0]);
825
	}
968 leency 826
}
827
 
828
void app_halt(){
829
 
830
	delete apppath;
831
	delete levpath;
832
	if (external_levels_available==true) {delete externallevels;}
833
	kos_ExitApp();
834
}
835
 
3132 leency 836
 
837
 
968 leency 838
void kos_Main(){
839
 
840
	load_external_levels();
841
 
3132 leency 842
	decode_graphics(576*0 + kosilka_gfx,kosilka_d);
843
	decode_graphics(576*1 + kosilka_gfx,kosilka_u);
844
	decode_graphics(576*2 + kosilka_gfx,kosilka_l);
845
	decode_graphics(576*3 + kosilka_gfx,kosilka_r);
846
	decode_graphics(576*4 + kosilka_gfx,skos);
847
	decode_graphics(576*5 + kosilka_gfx,stone);
848
	decode_graphics(576*6 + kosilka_gfx,tree);
849
	decode_graphics(576*7 + kosilka_gfx,grass);
968 leency 850
 
851
	for (;;){
852
 
853
		switch (kos_WaitForEvent()){
854
		case 1:
855
			w_redraw=true;
856
			draw_window();
857
			break;
858
		case 2:
859
			Byte keyCode;
860
			kos_GetKey(keyCode);
861
			if (status==1){
862
			if (gamestarted==true){
863
				switch (keyCode){
864
				case 177:
865
					if (kosilkay<19){
866
						if (gamearea[kosilkax][kosilkay+1]=='g'){
867
							gamearea[kosilkax][kosilkay]='n';
868
							gamearea[kosilkax][kosilkay+1]='k';
869
 
870
							if (drawanimation==true) {animate(kosilkax,kosilkay,1);}
871
 
872
 
873
							lastkosilkadirection=kosilkadirection;
874
							laststep=1;
875
 
876
							kosilkay++;
877
							kosilkadirection=1;
878
							draw_element(kosilkax,kosilkay);
879
							draw_element(kosilkax,kosilkay-1);
880
							display_grass_left();
881
							updateStatus();
882
						}
883
					}
884
					break;
885
				case 178:
886
					if (kosilkay>0){
887
						if (gamearea[kosilkax][kosilkay-1]=='g'){
888
							gamearea[kosilkax][kosilkay]='n';
889
							gamearea[kosilkax][kosilkay-1]='k';
890
 
891
							if (drawanimation==true) {animate(kosilkax,kosilkay,2);}
892
 
893
							lastkosilkadirection=kosilkadirection;
894
							laststep=2;
895
 
896
							kosilkay--;
897
							kosilkadirection=2;
898
 
899
							draw_element(kosilkax,kosilkay);
900
							draw_element(kosilkax,kosilkay+1);
901
							display_grass_left();
902
							updateStatus();
903
						}
904
					}
905
					break;
906
 
907
				case 179:
908
					if (kosilkax<19){
909
						if (gamearea[kosilkax+1][kosilkay]=='g'){
910
							gamearea[kosilkax][kosilkay]='n';
911
							gamearea[kosilkax+1][kosilkay]='k';
912
 
913
							if (drawanimation==true) {animate(kosilkax,kosilkay,3);}
914
 
915
 
916
							lastkosilkadirection=kosilkadirection;
917
							laststep=3;
918
 
919
							kosilkax++;
920
							kosilkadirection=4;
921
 
922
							draw_element(kosilkax,kosilkay);
923
							draw_element(kosilkax-1,kosilkay);
924
							display_grass_left();
925
							updateStatus();
926
						}
927
					}
928
					break;
929
 
930
				case 176:
931
					if (kosilkax>0){
932
						if (gamearea[kosilkax-1][kosilkay]=='g'){
933
							gamearea[kosilkax][kosilkay]='n';
934
							gamearea[kosilkax-1][kosilkay]='k';
935
 
936
							if (drawanimation==true) {animate(kosilkax,kosilkay,4);}
937
 
938
							lastkosilkadirection=kosilkadirection;
939
							laststep=4;
940
 
941
							kosilkax--;
942
							kosilkadirection=3;
943
 
944
							draw_element(kosilkax,kosilkay);
945
							draw_element(kosilkax+1,kosilkay);
946
							display_grass_left();
947
							updateStatus();
948
						}
949
					}
950
					break;
951
 
952
				case 27:
953
					if (lives>0){
954
						lives--;
955
						initializeLevel(level);
956
 
957
					} else {
958
						gamestarted=false;
959
						status=3;
960
						draw_window();
961
					}
962
					break;
963
 
964
				case 8:
965
					if (laststep!=0){
966
						kosilkadirection=lastkosilkadirection;
967
						if (laststep==1){
968
							gamearea[kosilkax][kosilkay]='g';
969
							gamearea[kosilkax][kosilkay-1]='k';
970
							draw_element(kosilkax,kosilkay);
971
							draw_element(kosilkax,kosilkay-1);
972
							kosilkay--;
973
						}
974
					if (laststep==2){
975
							gamearea[kosilkax][kosilkay]='g';
976
							gamearea[kosilkax][kosilkay+1]='k';
977
							draw_element(kosilkax,kosilkay);
978
							draw_element(kosilkax,kosilkay+1);
979
							kosilkay++;
980
						}
981
 
982
					if (laststep==3){
983
							gamearea[kosilkax][kosilkay]='g';
984
							gamearea[kosilkax-1][kosilkay]='k';
985
							draw_element(kosilkax,kosilkay);
986
							draw_element(kosilkax-1,kosilkay);
987
							kosilkax--;
988
						}
989
 
990
					if (laststep==4){
991
							gamearea[kosilkax][kosilkay]='g';
992
							gamearea[kosilkax+1][kosilkay]='k';
993
							draw_element(kosilkax,kosilkay);
994
							draw_element(kosilkax+1,kosilkay);
995
							kosilkax++;
996
						}
997
 
998
 
999
						laststep=0;
1000
					}
1001
					break;
1002
 
1003
				}
1004
 
1005
			}
1006
			}
1007
			if (status==0){
1008
				if (keyCode==13){ //enter
1009
					if (external_levels_available==true){
1010
						status=4;
1011
						draw_window();
1012
					}
1013
					else
1014
					{
1015
						status=1;
1016
						initializeLevel(1);
1017
						gamestarted=true;
1018
					}
1019
 
1020
				}
1021
 
1022
				if (keyCode==103){
1023
					if (drawgraphics==true){
1024
						drawgraphics=false;
1025
					} else {
1026
						drawgraphics=true;
1027
					}
1028
 
1029
					if (drawgraphics==true){
1030
						kos_PutImage((RGB*)kosilka_d,24,24,305,150);
1031
					}
1032
					else
1033
					{
1034
					kos_DrawBar(305,150,24,24,0x00AAAA);
1035
					}
1036
				}
1037
 
1038
				if (keyCode==97){
1039
					if (drawanimation==true){
1040
						drawanimation=false;
1041
					} else {
1042
						drawanimation=true;
1043
					}
1044
 
1045
					if (drawanimation==true){
1046
						kos_DrawBar(335,150,24,24,0x00AA00);
1047
					}
1048
					else
1049
					{
1050
						kos_DrawBar(335,150,24,24,0xAA0000);
1051
					}
1052
				}
1053
				if (keyCode==104){
1054
						status=-1;
1055
						draw_window();
1056
				}
1057
 
1058
				if (keyCode==27){
1059
					app_halt();
1060
				}
1061
 
1062
			}
1063
 
1064
			if (status==4){
1065
				if (keyCode==49){ //1
1066
						external_levels=false;
1067
						status=1;
1068
						initializeLevel(1);
1069
						gamestarted=true;
1070
 
1071
				}
1072
 
1073
				if (keyCode==50){ //2
1074
						external_levels=true;
1075
						levelcount=external_levels_count[0];
1076
						status=1;
1077
						initializeLevel(1);
1078
						gamestarted=true;
1079
 
1080
				}
1081
			}
1082
 
1083
			if (status==2){
1084
				if (keyCode==113){
1085
						lives=2;
1086
						status=0;
1087
						level=1;
1088
						draw_window();
1089
						gamestarted=true;
1090
				}
1091
			}
1092
 
1093
			if (status==3){
1094
				if (keyCode==113){
1095
						lives=2;
1096
						status=0;
1097
						level=1;
1098
						draw_window();
1099
						gamestarted=true;
1100
 
1101
				}
1102
				if (keyCode==114){
1103
						lives=2;
1104
						status=1;
1105
						level=1;
1106
						initializeLevel(1);
1107
						gamestarted=true;
1108
				}
1109
 
1110
			}
1111
 
1112
			if (status==-1){
1113
				if (keyCode==8){
1114
					status=0;
1115
					draw_window();
1116
				}
1117
			}
1118
 
1119
			break;
1120
		case 3:
1121
 
1122
			app_halt();
1123
			break;
1124
		}
1125
	}
1126
}