Subversion Repositories Kolibri OS

Rev

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