Subversion Repositories Kolibri OS

Rev

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

Rev 2276 Rev 2281
Line 1... Line 1...
1
//Leency 06.10.2011, Flood-it! v2.0, GPL
1
//Leency 06.10.2011, Flood-it! v2.1, GPL
Line 2... Line 2...
2
 
2
 
3
#include "lib\kolibri.h" 
3
#include "lib\kolibri.h" 
Line 4... Line 4...
4
#include "lib\random.h"
4
#include "lib\random.h"
Line 41... Line 41...
41
	"‡ ¯®«­¨â¥ ¯®«¥ ®¤­¨¬ 梥⮬ §  ®£à ­¨ç¥­­®¥ ç¨á«® 室®¢.",
41
	"‡ ¯®«­¨â¥ ¯®«¥ ®¤­¨¬ 梥⮬ §  ®£à ­¨ç¥­­®¥ ç¨á«® 室®¢.",
42
	"ˆ£à  ­ ç¨­ ¥âáï á ¢¥àå­¥© «¥¢®© ª«¥âª¨. ‚ë¡¥à¨â¥ 梥â, ­ ¦ ¢ ­  ®¤¨­ ¨§",
42
	"ˆ£à  ­ ç¨­ ¥âáï á ¢¥àå­¥© «¥¢®© ª«¥âª¨. ‚ë¡¥à¨â¥ 梥â, ­ ¦ ¢ ­  ®¤¨­ ¨§",
43
	"ª¢ ¤à â¨ª®¢ á«¥¢ , ¨ ª«¥âª¨ ®ªà áïâáï í⨬ 梥⮬ - â ª ¢ë ¯à¨á®¥¤¨­¨â¥",
43
	"ª¢ ¤à â¨ª®¢ á«¥¢ , ¨ ª«¥âª¨ ®ªà áïâáï í⨬ 梥⮬ - â ª ¢ë ¯à¨á®¥¤¨­¨â¥",
44
	"á®á¥¤­¨¥ ª«¥âª¨ ⮩ ¦¥ ®ªà áª¨. ‡ å¢ â¨âì ¯®«¥ ­ã¦­® §  ¬¨­¨¬ «ì­®¥",
44
	"á®á¥¤­¨¥ ª«¥âª¨ ⮩ ¦¥ ®ªà áª¨. ‡ å¢ â¨âì ¯®«¥ ­ã¦­® §  ¬¨­¨¬ «ì­®¥",
45
	"ç¨á«® 室®¢. ®è £®¢ ï áâà â¥£¨ï á ¨­â¥à¥á­ë¬ ¯à¨­æ¨¯®¬ - ¨§¬¥­¨áì,",
45
	"ç¨á«® 室®¢. ®è £®¢ ï áâà â¥£¨ï á ¨­â¥à¥á­ë¬ ¯à¨­æ¨¯®¬ - ¨§¬¥­¨áì,",
46
	"çâ®¡ë ¯®¡¥¤¨âì!", 0}; 
46
	"çâ®¡ë ¯®¡¥¤¨âì!",
-
 
47
	"",
-
 
48
	"ˆ£à âì â ª¦¥ ¬®¦­® ª« ¢¨è ¬¨:",
-
 
49
	"[Q] [W] [E]",
-
 
50
	"[A] [S] [D]",
-
 
51
	0}; 
47
#else
52
#else
48
	char *BUTTON_CAPTIONS[]={ "New Game [F2]", "Help     [F1]", "Exit    [Esc]", 0}; 
53
	char *BUTTON_CAPTIONS[]={ "New Game [F2]", "Help     [F1]", "Exit    [Esc]", 0}; 
49
	char CLICKS_TEXT[]="Clicks:   /";
54
	char CLICKS_TEXT[]="Clicks:   /";
50
	char LEVELS_TEXT[]="Board:";
55
	char LEVELS_TEXT[]="Board:";
Line 51... Line 56...
51
	
56
	
52
	char HELP_WINDOW_CAPTION[]="Help";
57
	char HELP_WINDOW_CAPTION[]="Help";
53
	char *HELP_TEXT[]={	"How to play Flood-it?",
58
	char *HELP_TEXT[]={	"How to play Flood-it?",
54
	"",
59
	"",
55
	"Flood the whole board with one color within the allowed steps.",
60
	"Flood the whole board with one color within the allowed steps.",
56
	"You start from the top left corner and progress by selecting one",
61
	"You start from the top left corner and progress by selecting one",
57
	"of the colored balls on the left. When you change your current area",
62
	"of the colored buttons on the left. When you change your current area",
58
	"color, every adjacent square with the same color also changes, that",
63
	"color, every adjacent square with the same color also changes, that",
59
	"way you can flood other areas of the board. Select from 3 sizes of",
64
	"way you can flood other areas of the board. Select from 3 sizes of",
60
	"the board and try to flood-it in the least amount of steps!",
65
	"the board and try to flood-it in the least amount of steps!",
-
 
66
	"Addictive and Fun!",
-
 
67
	"",
-
 
68
	"You can also play with keyboard:",
-
 
69
	"[Q] [W] [E]",
-
 
70
	"[A] [S] [D]",
61
	"Addictive and Fun!", 0};
71
	0}; 
Line 62... Line 72...
62
#endif
72
#endif
Line 111... Line 121...
111
			case evButton:
121
			case evButton:
112
				id = GetButtonID(); 
122
				id = GetButtonID(); 
113
				if (id==1) || (id==4) ExitProcess();
123
				if (id==1) || (id==4) ExitProcess();
114
				if (id==2) goto _NEW_GAME_MARK;
124
				if (id==2) goto _NEW_GAME_MARK;
115
				if (id==3) goto _HELP_MARK;
125
				if (id==3) goto _HELP_MARK;
116
				if (id>=100)
-
 
117
				{
-
 
118
					if (color_matrix[0]==id-100) break; //åñëè öâåò ïåðâîé ôèøêè òàêîé æå, èãíîðèðóåì áåññìûñëåííûé õîä
-
 
119
					if (CLICKS>=MAX_CLICKS) break; //åñëè èãðà çàêîí÷åíà
-
 
120
					
-
 
121
					CLICKS++;
-
 
122
					draw_clicks_num();
-
 
123
					
-
 
124
					fill_field(id-100);
126
				if (id>=100) make_turn(id-100);
125
					draw_field();
-
 
126
					check_for_end(); //åñëè èãðà çàêîí÷åíà
-
 
127
					break;
-
 
128
				}
-
 
129
				if (id>=10)
127
				if (id>=10)
130
				{
128
				{
131
					id=id-10*3;
129
					id=id-10*3;
Line 132... Line 130...
132
					
130
					
Line 137... Line 135...
137
					MAX_CLICKS = DIFFICULTY_LEV_PARAMS[id+2]; //ìàêñèìàëüíîå êîëè÷åñòâî êëèêîâ äî âûèãðûøà
135
					MAX_CLICKS = DIFFICULTY_LEV_PARAMS[id+2]; //ìàêñèìàëüíîå êîëè÷åñòâî êëèêîâ äî âûèãðûøà
Line 138... Line 136...
138
					
136
					
Line 139... Line 137...
139
					new_game();
137
					new_game();
140
					
-
 
141
					MoveSize(-1, -1, BLOCK_SIZE*BLOCKS_NUM +14+USER_PANEL_WIDTH, BLOCK_SIZE*BLOCKS_NUM +GetSkinWidth()+14);
138
					
142
					break;
139
					MoveSize(-1, -1, BLOCK_SIZE*BLOCKS_NUM +14+USER_PANEL_WIDTH, BLOCK_SIZE*BLOCKS_NUM +GetSkinWidth()+14);
143
				}
140
				}
144
				break;
141
				break;
145
			case evKey:
142
			case evKey:
Line 156... Line 153...
156
					_NEW_GAME_MARK:
153
					_NEW_GAME_MARK:
157
						new_game();
154
						new_game();
158
						draw_clicks_num();
155
						draw_clicks_num();
159
						draw_field();
156
						draw_field();
160
				}
157
				}
-
 
158
				if (key==113) make_turn(0); //Q
-
 
159
				if (key==119) make_turn(1); //W
-
 
160
				if (key==101) make_turn(2); //E
-
 
161
				if (key==097) make_turn(3); //A
-
 
162
				if (key==115) make_turn(4); //S
-
 
163
				if (key==100) make_turn(5); //D
161
				break;
164
				break;
162
			case evReDraw:
165
			case evReDraw:
163
				draw_window();
166
				draw_window();
164
		}
167
		}
165
	}
168
	}
166
}
169
}
Line -... Line 170...
-
 
170
 
-
 
171
 
-
 
172
void make_turn(int turn_id)
-
 
173
{
-
 
174
	if (color_matrix[0]==turn_id) return; //åñëè öâåò ïåðâîé ôèøêè òàêîé æå, èãíîðèðóåì áåññìûñëåííûé õîä
-
 
175
	if (CLICKS>=MAX_CLICKS) return; //åñëè èãðà çàêîí÷åíà
-
 
176
	
-
 
177
	CLICKS++;
-
 
178
	draw_clicks_num();
-
 
179
	
-
 
180
	fill_field(turn_id);
-
 
181
	draw_field();
-
 
182
	check_for_end(); //åñëè èãðà çàêîí÷åíà	
-
 
183
}
167
 
184
 
168
 
185
 
169
void draw_window()
186
void draw_window()
170
{
187
{
Line 396... Line 413...
396
				if (GetKey()==27) ExitProcess(); //Esc
413
				if (GetKey()==27) ExitProcess(); //Esc
397
				break;
414
				break;
398
		CASE evReDraw:
415
		CASE evReDraw:
399
				for (i=0; HELP_TEXT[i]<>0; i++;) {};
416
				for (i=0; HELP_TEXT[i]<>0; i++;) {};
Line 400... Line 417...
400
				
417
				
Line 401... Line 418...
401
				DefineAndDrawWindow(500,200,450,i*13+50,0x34,sc.work,0,0,#HELP_WINDOW_CAPTION);
418
				DefineAndDrawWindow(500,200,450,i*13+44,0x34,sc.work,0,0,#HELP_WINDOW_CAPTION);
402
				
419
				
403
				WriteText(6,12,0x80,sc.work_text,HELP_TEXT[0],0); //ýòî äëÿ æèðíîãî øðèôòà
420
				WriteText(6,12,0x80,sc.work_text,HELP_TEXT[0],0); //ýòî äëÿ æèðíîãî øðèôòà
404
				for (i=0; HELP_TEXT[i]<>0; i++;) WriteText(5,i*13+12,0x80,sc.work_text,HELP_TEXT[i],0);
421
				for (i=0; HELP_TEXT[i]<>0; i++;) WriteText(5,i*13+12,0x80,sc.work_text,HELP_TEXT[i],0);