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