Subversion Repositories Kolibri OS

Rev

Rev 3137 | Rev 7333 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3137 Rev 7332
Line 1... Line 1...
1
/*	------- ÊÎÑÈËÊÀ ÄËß ÊÎËÈÁÐÈ -------
1
/*	------- KOSILKA FOR KOLIBI -------
2
Èãðà ïèøåòñÿ íà C++ (èñïîëüçóåòñÿ MS Visual C++ 6.0+).
2
Written in C++ (MS Visual C++ 6.0+).
3
Ýòî - èñõîäíèê âåðñèè 1.15.
3
Version 1.16.
Line 4... Line 4...
4
  
4
  
5
					 Andrey Mihaylovich aka Dron2004
5
					 Andrey Mihaylovich aka Dron2004
Line 6... Line -...
6
*/
-
 
7
 
6
*/
8
 
7
 
9
 
8
 
Line 10... Line -...
10
#include "kosSyst.h"
-
 
11
#include "kosFile.h"
9
#include "kosSyst.h"
12
#include "images.cpp"
10
#include "kosFile.h"
13
 
11
#include "images.cpp"
14
 
12
 
15
 
13
 
16
//ÂÍÅØÍÈÅ ÓÐÎÂÍÈ
14
//External levels
17
bool external_levels_available=false;
15
bool external_levels_available=false;
Line 18... Line 16...
18
bool external_levels = false;
16
bool external_levels = false;
19
int level_read_result;
17
int level_read_result;
Line 20... Line 18...
20
Byte * externallevels;
18
Byte * externallevels;
21
Byte external_levels_count[1] = {0};
19
Byte external_levels_count[1] = {0};
22
/////////////////
20
/////////////////
23
 
21
 
Line -... Line 22...
-
 
22
int lastkosilkadirection=1;
24
int lastkosilkadirection=1;
23
int laststep=0; //Last step. 0-does not exists, 1-bottom, 2-up, 3-left, 4-right
25
int laststep=0; //Ïîñëåäíèé õîä. 0-íåáûëî, 1-âíèç, 2-ââåðõ, 3-âëåâî, 4-âïðàâî
24
 
-
 
25
 
-
 
26
Byte skindata[13824];
-
 
27
int read_result=0;
-
 
28
bool skin_available=false;
-
 
29
bool w_redraw=true;
-
 
30
 
-
 
31
#if LANG == RUS
-
 
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[]     = "<­ ¦¬¨â¥  ¤«ï ⮣®, ç⮡ë áë£à âì ¥éñ à §>";
26
 
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[]     = "<­ ¦¬¨â¥  çâ®¡ë ¢ëª«îç¨âì/¢ª«îç¨âì ᪨­>";
-
 
45
	const char level[]       = "“஢¥­ì:";
-
 
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[]     = " to return to the menu>";
-
 
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";
Line 27... Line 57...
27
 
57
	const char press_enter[] = "press ENTER to start the game";
Line -... Line 58...
-
 
58
	const char press_g[]     = " to switch graphics mode>";
Line -... Line 59...
-
 
59
	const char press_a[]     = " to turn on/off animation>";
28
Byte skindata[13824];
60
	const char press_h[]     = " to view information about the program>";
29
int read_result=0;
61
	const char press_s[]     = " to turn on/off external skin>";
30
bool skin_available=false;
62
	const char level[]       = "Level:";
31
bool w_redraw=true;
63
	const char attempts_left[] = "Attempts left:";
32
 
64
	const char grass_left[]  = "Grass left:";
33
const char windowTitle[]="Š®á¨«ª  ¤«ï Š®«¨¡à¨";
65
#endif
34
const char version[]="‚¥àá¨ï 1.15";
66
 
35
int levelcount=7; //×èñëî óðîâíåé
67
int levelcount=7;
36
 
68
 
37
char gamearea[20][20]; //Êàðòà
69
char gamearea[20][20]; //The map
38
 
70
 
39
 
71
 
40
short int kosilkax; // Ïîëîæåíèå êîñèëêè
72
short int kosilkax; // Kosilka position
41
short int kosilkay;
73
short int kosilkay;
42
short int kosilkadirection=1; //Íàïðàâëåíèå ïðîøëîãî øàãà. 1-âíèç, 2-ââåðõ, 3-âëåâî, 4-âïðàâî
74
short int kosilkadirection=1; //Last step direction. 1-bottom, 2-up, 3-left, 4-right
43
short int lives=2; // Æèçíè
75
short int lives=2;
Line 44... Line 76...
44
short int level=1; //Óðîâåíü
76
short int level=1;
45
short int status=0; //Ãäå 0 - ïðèâåòñòâèå
77
short int status=0; //Where 0 - welcome screen
46
					// 1 - èãðà
78
					// 1 - the game
47
					// 2 - èãðà ïðîéäåíà
79
					// 2 - win
48
					// 3 - âû ïðîèãðàëè
80
					// 3 - fail
49
					// 4 - âûáîð íàáîðà óðîâíåé (âñòðîåííûé èëè âíåøíèé)
81
					// 4 - select the level (internal or external)
50
					// -1 - î ïðîãðàììå
82
					// -1 - about
51
bool gamestarted=false; //Áëîêèðîâêà èãðîâûõ êëàâèø. Åñëè false - èãðàòü íåëüçÿ
83
bool gamestarted=false; //Key locker. If "false" then not possible to play
Line 52... Line 84...
52
 
84
 
53
bool drawgraphics=true; //Ðèñîâàòü ëè äåòàëüíóþ ãðàôèêó (èëè îãðàíè÷èòüñÿ àñêåòè÷íîé)
85
bool drawgraphics=true; //Draw detailed graphics or just colored rectangles
54
bool drawanimation=true; //Àíèìèðîâàòü ëè
86
bool drawanimation=true;
Line 55... Line 87...
55
int grassLeft();  //Ñîîáùèì î íàëè÷èè ôóíêöèè Grass Left
87
int grassLeft();  //Notify about "Grass Left" function
Line 89... Line 121...
89
 
121
 
90
	return levpath;
122
	return levpath;
Line 91... Line 123...
91
}
123
}
92
 
124
 
93
 
125
 
94
void interlevelpause(){ //Ïàóçà ìåæäó óðîâíÿìè
126
void interlevelpause(){ //The pause between levels
95
	Byte tempCode;
127
	Byte tempCode;
96
	RGB tmprgb;
128
	RGB tmprgb;
Line 107... Line 139...
107
			tmpa++;
139
			tmpa++;
108
			if (tmpa>9) tmpa=0;
140
			if (tmpa>9) tmpa=0;
109
		}
141
		}
110
}
142
}
Line 111... Line 143...
111
 
143
 
112
void draw_element(int elx, int ely){ //Îòðèñîâêà ýëåìåíòà êàðòû
144
void draw_element(int elx, int ely){ //Draw map element
113
switch (gamearea[elx][ely]){
145
switch (gamearea[elx][ely]){
114
			case 'g':
146
			case 'g':
115
				if (drawgraphics==true){
147
				if (drawgraphics==true){
116
					kos_PutImage((RGB*)grass,24,24,elx*24,ely*24);
148
					kos_PutImage((RGB*)grass,24,24,elx*24,ely*24);
Line 182... Line 214...
182
			}
214
			}
Line 183... Line 215...
183
 
215
 
Line 184... Line 216...
184
}
216
}
185
 
217
 
186
 
218
 
187
void display_grass_left(){ //Âûâîäèì íà ýêðàí êîëè÷åñòâî îñòàâøåéñÿ òðàâû
219
void display_grass_left(){
Line 188... Line 220...
188
	kos_DrawBar(605,120,20,10,0xEEEEEE);
220
	kos_DrawBar(605,120,20,10,0xEEEEEE);
189
	kos_DisplayNumberToWindow(grassLeft(),3,605,120,0x0000FF,nbDecimal,false);
221
	kos_DisplayNumberToWindow(grassLeft(),3,605,120,0x0000FF,nbDecimal,false);
Line 190... Line 222...
190
}
222
}
191
 
223
 
192
 
224
 
Line 247... Line 279...
247
			break;
279
			break;
248
	}
280
	}
249
}
281
}
Line 250... Line 282...
250
 
282
 
251
 
283
 
Line 252... Line 284...
252
void draw_window(void){ //Ïåðåðèñîâêà îêíà
284
void draw_window(void){
253
	sProcessInfo sPI;
285
	sProcessInfo sPI;
254
	
286
	
255
	if (w_redraw)
287
	if (w_redraw)
256
	{
288
	{
257
		kos_WindowRedrawStatus(1); //Íà÷àëî ïåðåðèñîâêè
289
		kos_WindowRedrawStatus(1);
258
		kos_DefineAndDrawWindow(50,50,640,506-22+kos_GetSkinHeight(),0x74,0xEEEEEE,0,0,(Dword)windowTitle);
290
		kos_DefineAndDrawWindow(50,50,640,506-22+kos_GetSkinHeight(),0x74,0xEEEEEE,0,0,(Dword)windowTitle);
Line 259... Line 291...
259
		kos_WindowRedrawStatus(2); //Êîíåö ïåðåðèñîâêè
291
		kos_WindowRedrawStatus(2);
260
	}
292
	}
Line 261... Line 293...
261
	w_redraw=false;
293
	w_redraw=false;
262
 
294
 
263
	kos_ProcessInfo( &sPI );
295
	kos_ProcessInfo( &sPI );
264
	if (sPI.rawData[70]&0x04) return; //íè÷åãî íå äåëàòü åñëè îêíî ñõëîïíóòî â çàãîëîâîê
296
	if (sPI.rawData[70]&0x04) return; //do nothing if window is rolled-up into title
Line 265... Line 297...
265
 
297
 
266
	//Ïåðåðèñîâêà êàðòû
298
	//Map redraw
Line 267... Line 299...
267
	if ((status!=0)&&(status!=-1)&&(status!=4))
299
	if ((status!=0)&&(status!=-1)&&(status!=4))
268
	{
300
	{
Line 269... Line 301...
269
		kos_DrawBar(631-151,0,151,480,0xEEEEEE);
301
		kos_DrawBar(631-151,0,151,480,0xEEEEEE);
270
 
302
 
Line 271... Line 303...
271
		kos_WriteTextToWindow(500,30,0x80, 0 ,"Š  Ž  ‘  ˆ  ‹  Š  €",19);
303
		kos_WriteTextToWindow(500,30,0x80, 0, (char*)k_o_s_i_l_k,19);
272
		kos_WriteTextToWindow(517,40,0x80, 0 ,"¤«ï Š®«¨¡à¨ Ž‘",14);
304
		kos_WriteTextToWindow(517,40,0x80, 0, (char*)for_kolibri,14);
Line 273... Line 305...
273
 
305
 
Line 274... Line 306...
274
		kos_WriteTextToWindow(495,80,0x80, 0 ,"“஢¥­ì:",6);
306
		kos_WriteTextToWindow(495,80,0x80, 0, (char*)level,6);
275
		kos_DisplayNumberToWindow(level,3,605,80,0x0000FF,nbDecimal,false);
307
		kos_DisplayNumberToWindow(level,3,605,80,0x0000FF,nbDecimal,false);
Line 276... Line 308...
276
 
308
 
277
		kos_WriteTextToWindow(495,95,0x80, 0 ,"Žáâ «®áì ¯®¯ë⮪:",11);
309
		kos_WriteTextToWindow(495,95,0x80, 0, (char*)attempts_left,11);
278
		kos_DisplayNumberToWindow(lives,1,605,95,0x0000FF,nbDecimal,false);
310
		kos_DisplayNumberToWindow(lives,1,605,95,0x0000FF,nbDecimal,false);
279
 
-
 
Line 280... Line 311...
280
		kos_WriteTextToWindow(495,120,0x80, 0 ,"Žáâ «®áì âà ¢ë:",11);
311
 
281
		display_grass_left();
312
		kos_WriteTextToWindow(495,120,0x80, 0, (char*)grass_left,11);
282
 
313
		display_grass_left();
Line 318... Line 349...
318
		else
349
		else
319
		{
350
		{
320
			kos_DrawBar(335,150,24,24,0xAA0000);
351
			kos_DrawBar(335,150,24,24,0xAA0000);
321
		}
352
		}
Line 322... Line 353...
322
 
353
 
323
                kos_WriteTextToWindow(255,200,0x80, 0xFFFFFF ,"Š   Ž   ‘   ˆ   ‹   Š   €",19);
354
                kos_WriteTextToWindow(255, 200,0x80, 0xFFFFFF, (char*)k_o_s_i_l_k, 19);
324
                kos_WriteTextToWindow(290, 220,0x80, 0xFFFFFF ,"¤«ï Š®«¨¡à¨ Ž‘",14);
355
                kos_WriteTextToWindow(290, 220,0x80, 0xFFFFFF, (char*)for_kolibri, 14);
325
                kos_WriteTextToWindow(239, 240,0x80, 0xFFFFFF ,"<¤«ï ­ ç «  ¨£àë ­ ¦¬¨â¥ ENTER>",30);
356
                kos_WriteTextToWindow(239, 240,0x80, 0xFFFFFF, (char*)press_enter, 30);
326
                kos_WriteTextToWindow(30, 380,0x80, 0xFFFFFF ,"<­ ¦¬¨â¥  ¤«ï ¯¥à¥ª«î祭¨ï ०¨¬  £à ä¨ª¨>",53);
357
                kos_WriteTextToWindow(30,  380,0x80, 0xFFFFFF, (char*)press_g, 53);
327
                kos_WriteTextToWindow(30, 400,0x80, 0xFFFFFF ,"<­ ¦¬¨â¥  ¤«ï ¢ª«î祭¨ï/¢ëª«î祭¨ï  ­¨¬ æ¨¨>",41);
358
                kos_WriteTextToWindow(30,  400,0x80, 0xFFFFFF, (char*)press_a, 41);
328
                kos_WriteTextToWindow(30, 420,0x80, 0xFFFFFF ,"<­ ¦¬¨â¥  ¤«ï ¯à®á¬®âà  á¢¥¤¥­¨© ® ¯à®£à ¬¬¥>",32);
359
                kos_WriteTextToWindow(30,  420,0x80, 0xFFFFFF, (char*)press_h, 32);
329
                if (skin_available==true) {kos_WriteTextToWindow(30, 440,0x80, 0xFFFFFF ,"<­ ¦¬¨â¥  çâ®¡ë ¢ëª«îç¨âì/¢ª«îç¨âì ᪨­>",27);}
-
 
Line 330... Line 360...
330
 
360
                if (skin_available==true) kos_WriteTextToWindow(30, 440,0x80, 0xFFFFFF, (char*)press_s, 27);
331
 
361
 
Line 337... Line 367...
337
		kos_WriteTextToWindow(533, 440,0x80, 0xFFFFFF ,(char*)version,0);
367
		kos_WriteTextToWindow(533, 440,0x80, 0xFFFFFF ,(char*)version,0);
338
	}
368
	}
339
	if (status==2){
369
	if (status==2){
340
	   kos_DrawBar(10,150,610,200,0x528B4C);	
370
	   kos_DrawBar(10,150,610,200,0x528B4C);	
341
	   kos_DrawBar(15,155,601,190,0x3BCF46);	
371
	   kos_DrawBar(15,155,601,190,0x3BCF46);	
342
           kos_WriteTextToWindow(240,230,0x80, 0xFFFFFF ,"‚ë ¢ë¨£à «¨!",13);
372
           kos_WriteTextToWindow(240,230,0x80, 0xFFFFFF ,(char*)win,13);
343
           kos_WriteTextToWindow(240,250,0x80, 0xFFFFFF ,"<­ ¦¬¨â¥ q ¤«ï ¢®§¢à â  ¢ ¬¥­î>",17);
373
           kos_WriteTextToWindow(240,250,0x80, 0xFFFFFF ,(char*)press_q,17);
344
	}
374
	}
345
	if (status==3){
375
	if (status==3){
346
	   kos_DrawBar(10,150,610,200,0x8B4C4C);	
376
	   kos_DrawBar(10,150,610,200,0x8B4C4C);	
347
	   kos_DrawBar(15,155,601,190,0xCF3B3B);	
377
	   kos_DrawBar(15,155,601,190,0xCF3B3B);	
348
           kos_WriteTextToWindow(220,220,0x80, 0xFFFFFF ,"ˆ£à  ®ª®­ç¥­ ...",13);
378
           kos_WriteTextToWindow(220,220,0x80, 0xFFFFFF ,(char*)fail,13);
349
           kos_WriteTextToWindow(220,240,0x80, 0xFFFFFF ,"<­ ¦¬¨â¥ r ¤«ï ⮣®, ç⮡ë áë£à âì ¥éñ à §>",23);
379
           kos_WriteTextToWindow(220,240,0x80, 0xFFFFFF ,(char*)press_r,23);
350
           kos_WriteTextToWindow(220,260,0x80, 0xFFFFFF ,"<­ ¦¬¨â¥ q ¤«ï ¢®§¢à â  ¢ ¬¥­î>",17);
380
           kos_WriteTextToWindow(220,260,0x80, 0xFFFFFF ,(char*)press_q,17);
351
	}
381
	}
352
	if (status==-1){
382
	if (status==-1){
Line 353... Line 383...
353
 
383
 
354
		kos_DrawBar(0,0,4,480,0x000000);
384
		kos_DrawBar(0,0,4,480,0x000000);
Line 364... Line 394...
364
					kos_PutImage((RGB*)skos,24,24,4+tmpppx*24,tmpppy*24);
394
					kos_PutImage((RGB*)skos,24,24,4+tmpppx*24,tmpppy*24);
365
				}
395
				}
366
			}
396
			}
367
		}
397
		}
Line 368... Line 398...
368
 
398
 
369
           kos_WriteTextToWindow(40,40,0x80, 0xFFFFFF ,"Š®á¨«ª  ¤«ï Ž‘ Š®«¨¡à¨",22);
399
		kos_WriteTextToWindow(40,40,0x80, 0xFFFFFF ,(char*)windowTitle,22);
370
	   kos_WriteTextToWindow(40,60,0x80, 0xFFFFFF ,(char*)version,12);
400
		kos_WriteTextToWindow(40,60,0x80, 0xFFFFFF ,(char*)version,12);
Line 371... Line 401...
371
	   kos_WriteTextToWindow(40,75,0x80, 0xFFFFFF ,"________________________________________",40);
401
		kos_WriteTextToWindow(40,75,0x80, 0xFFFFFF ,"________________________________________",40);
372
	   
402
	   
Line 380... Line 410...
380
			kos_WriteTextToWindow(40,270,0x80, 0x99FF99 ,"diamond - ¨¤¥ï ®â¬¥­ë 室 , â¥áâ¨à®¢ ­¨¥",49);
410
		kos_WriteTextToWindow(40,270,0x80, 0x99FF99 ,"diamond - ¨¤¥ï ®â¬¥­ë 室 , â¥áâ¨à®¢ ­¨¥",49);
Line 381... Line 411...
381
 
411
 
382
           kos_WriteTextToWindow(40,300,0x80, 0x88FF88 ,"Žâ¤¥«ì­®¥ ᯠᨡ®:",16);
412
		kos_WriteTextToWindow(40,300,0x80, 0x88FF88 ,"Žâ¤¥«ì­®¥ ᯠᨡ®:",16);
Line 383... Line -...
383
           kos_WriteTextToWindow(40,330,0x80, 0x77FF77 ,"‚ᥬ, ªâ® ¨£à ¥â ¢ íâã ¨£àã :-) !",50);
-
 
384
 
413
		kos_WriteTextToWindow(40,330,0x80, 0x77FF77 ,"‚ᥬ, ªâ® ¨£à ¥â ¢ íâã ¨£àã :-) !",50);
385
 
414
 
Line 386... Line 415...
386
           kos_WriteTextToWindow(40,430,0x80, 0x66FF66 ,"­ ¦¬¨â¥  ¤«ï ¢®§¢à â  ¢ ¬¥­î",35);
415
		kos_WriteTextToWindow(40,430,0x80, 0x66FF66 ,"­ ¦¬¨â¥  ¤«ï ¢®§¢à â  ¢ ¬¥­î",35);
Line 411... Line 440...
411
 
440
 
Line 412... Line 441...
412
}
441
}
413
 
442
 
414
 
443
 
415
 
444
 
416
//Îïèñàíèå óðîâíåé èãðû
445
//Game level description,
417
//, ãäå	k - êîñèëêà
446
//where k - kosilka
418
//		g - òðàâà
447
//		g - grass
419
//		n - ñêîøåííàÿ òðàâà
448
//		n - cut grass
420
//		s - êàìåíü
449
//		s - stone
Line 421... Line 450...
421
//		t - äåðåâî
450
//		t - tree
Line 662... Line 691...
662
			}
691
			}
663
		}		
692
		}		
664
		}
693
		}
665
		else
694
		else
666
		{
695
		{
667
			//ÂÍÅØÍÈÅ ÓÐÎÂÍÈ
696
			//External levels
668
			kosilkadirection=1;
697
			kosilkadirection=1;
Line 669... Line 698...
669
 
698
 
670
			int currentrow=0;
699
			int currentrow=0;
Line 702... Line 731...
702
 
731
 
Line 703... Line 732...
703
	draw_window();
732
	draw_window();
Line 704... Line -...
704
 
-
 
705
}
733
 
706
 
734
}
707
//Ïðåîâåðÿåì îñòàòîê òðàâû
735
 
708
int grassLeft(){
736
int grassLeft(){
709
	int leftgrass=0;
737
	int leftgrass=0;
Line 715... Line 743...
715
		}
743
		}
716
	}
744
	}
717
	return leftgrass;
745
	return leftgrass;
718
}
746
}
Line 719... Line -...
719
 
-
 
720
 
747
 
721
//Ìåíÿåì óðîâåíü èëè âûâîäèì ñîîáùåíèå î òîì, ÷òî âñå óðîâíè ïðîéäåíû
748
//Change level or show win message 
Line 722... Line 749...
722
void updateStatus(){
749
void updateStatus(){
723
 
750
 
724
	if (grassLeft()==0) {
751
	if (grassLeft()==0) {
Line 736... Line 763...
736
	}
763
	}
Line 737... Line 764...
737
	
764
	
Line 738... Line -...
738
}
-
 
739
 
765
}
Line 740... Line 766...
740
 
766
 
Line 741... Line 767...
741
 
767
 
Line 1056... Line 1082...
1056
			app_halt();
1082
			app_halt();
1057
			break;
1083
			break;
1058
		}
1084
		}
1059
	}
1085
	}
1060
}
1086
}
1061
 
-
 
1062
// Êîíåö èñõîäíèêà
-
 
1063
>
1087
>