Subversion Repositories Kolibri OS

Rev

Rev 7345 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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