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