Subversion Repositories Kolibri OS

Rev

Rev 6167 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2794 leency 1
 
3587 fedesco 2
#include "lib\random.h"
2794 leency 3
7984 leency 4
 
5
6
 
2794 leency 7
8
 
9
int DIFFICULTY_LEVEL=1; //по-умолчанию среднее поле
2842 leency 10
char *BOARD_SIZES[]={ "S", "M", "L", 0 };
7984 leency 11
int DIFFICULTY_LEV_PARAMS[]={ 9, 12, 16 };
2794 leency 12
13
 
14
int BLOCKS_LEFT; //блоков осталось
15
int blocks_matrix[28*28]; //цвета для поля с квадратиками
16
17
 
18
#define BLOCK_SIZE 21 //размер квадратика
19
#define MARKED 7
20
#define DELETED_BLOCK 6
21
#define HEADER "Just Clicks v2.2"
6167 leency 22
2794 leency 23
 
2797 leency 24
#include "lang.h--"
25
#endif
26
27
 
2794 leency 28
	#define NEW_GAME_TEXT "‡ ­®ў® [F2]"
7984 leency 29
	#define RESULT_TEXT   "ђҐ§г«мв в: "
30
#elif LANG_EST
3933 kaitz 31
	#define NEW_GAME_TEXT "Uus mдng [F2]"
7984 leency 32
	#define RESULT_TEXT   "Tulemus: "
33
#else
2794 leency 34
	#define NEW_GAME_TEXT "New Game [F2]"
7984 leency 35
	#define RESULT_TEXT   "Result: "
36
#endif
2794 leency 37
38
 
39
 
40
{
3587 fedesco 41
	int id;
7984 leency 42
3587 fedesco 43
 
2842 leency 44
3587 fedesco 45
 
2794 leency 46
3587 fedesco 47
 
2794 leency 48
		switch(WaitEvent())
3587 fedesco 49
		{
2794 leency 50
			case evButton:
51
				id = @GetButtonID();
7984 leency 52
				if (id==1) ExitProcess();
2794 leency 53
				if (id==2) || (id==3) goto _NEW_GAME_MARK;
3776 leency 54
				if (id>=100)
2794 leency 55
				{
56
					if (check_for_end()) break; //если игра закончена
57
3587 fedesco 58
 
2794 leency 59
					draw_field();
60
3587 fedesco 61
 
2794 leency 62
3587 fedesco 63
 
2794 leency 64
				}
65
				if (id==10) //изменяем размер поля
66
				{
67
					if (DIFFICULTY_LEVEL<2) DIFFICULTY_LEVEL++; else DIFFICULTY_LEVEL=0;
68
3587 fedesco 69
 
2794 leency 70
3587 fedesco 71
 
2794 leency 72
3587 fedesco 73
 
7984 leency 74
					break;
2794 leency 75
				}
76
				break;
77
			case evKey:
78
				@GetKeyScancode();
7984 leency 79
				if (AL==001) //Escape
80
					 ExitProcess();
2794 leency 81
				if (AL==060) //F2
7984 leency 82
				{
2794 leency 83
					_NEW_GAME_MARK:
84
						new_game();
85
						draw_clicks_num();
86
						draw_field();
87
				}
88
				break;
89
			case evReDraw:
90
				draw_window();
91
		}
92
}
93
94
 
95
 
96
{
97
	int i, j,
98
	marked_num=1,
99
	old_marker=blocks_matrix[button_id],
100
	restart;
101
102
 
103
104
 
105
	_RESTART_MARK:
106
	restart=0;
107
	for (i=0;i
108
		for (j=0;j
109
		{
110
			if (blocks_matrix[i*BLOCKS_NUM+j]<>old_marker) continue; //если фишка не нужного цвета идём дальше
111
			if (blocks_matrix[i*BLOCKS_NUM+j]==MARKED) continue; //если фишка уже отмечена, идём далее
112
3587 fedesco 113
 
2794 leency 114
			if (i>0) && (blocks_matrix[i-1*BLOCKS_NUM+j]==MARKED) blocks_matrix[i*BLOCKS_NUM+j]=MARKED; //смотрим верхний
115
			if (j
116
			if (i
117
3587 fedesco 118
 
2794 leency 119
			{
120
				restart=1;
121
				marked_num++;
122
			}
123
		}
124
	if (restart) goto _RESTART_MARK;
125
3587 fedesco 126
 
2794 leency 127
	{
128
		blocks_matrix[button_id]=old_marker;
129
		return;
130
	}
131
132
 
133
	_2_RESTART_MARK:
134
	restart=0;
135
	for (i=BLOCKS_NUM;i>0;i--)
136
		for (j=BLOCKS_NUM;j>=0;j--)
137
		{
138
			if (blocks_matrix[i*BLOCKS_NUM+j]==MARKED) && (blocks_matrix[i-1*BLOCKS_NUM+j]<>blocks_matrix[i*BLOCKS_NUM+j])
139
			{
140
				blocks_matrix[i*BLOCKS_NUM+j]>
141
				restart=1;
142
			}
143
		}
144
	if (restart) goto _2_RESTART_MARK;
145
3587 fedesco 146
 
2794 leency 147
	for (i=0;i
3587 fedesco 148
			if (blocks_matrix[i]==MARKED)
2794 leency 149
				blocks_matrix[i]=DELETED_BLOCK;
150
3587 fedesco 151
 
2794 leency 152
	restart=BLOCKS_NUM; //не придумал ничего лучше :(
153
3587 fedesco 154
 
2794 leency 155
	for (j=0;j
156
		if (blocks_matrix[BLOCKS_NUM-1*BLOCKS_NUM+j]==DELETED_BLOCK)
157
		{
158
			for (i=0;i
159
				blocks_matrix[i*BLOCKS_NUM+j]>
160
		}
161
	restart--;
162
	if (restart) goto _3_RESTART_MARK;
163
}
164
165
 
166
 
167
{
168
	int PANEL_Y;
4254 leency 169
	proc_info Form;
2794 leency 170
3587 fedesco 171
 
2794 leency 172
	DefineAndDrawWindow(300,176, BLOCK_SIZE*BLOCKS_NUM +9, BLOCK_SIZE*BLOCKS_NUM +GetSkinHeight()+4+USER_PANEL_HEIGHT,
7984 leency 173
		0x74,sc.work,0,0,HEADER);
3587 fedesco 174
175
 
2794 leency 176
	GetProcessInfo(#Form, SelfInfo);
177
	if (Form.status_window>2) return;
178
179
 
180
 
181
182
 
183
3587 fedesco 184
 
7984 leency 185
	DrawCaptButton(105,PANEL_Y+7, 20, 20, 10,sc.work_button, sc.work_button_text,BOARD_SIZES[DIFFICULTY_LEVEL]);
6167 leency 186
2794 leency 187
 
188
3587 fedesco 189
 
2794 leency 190
}
191
192
 
193
 
194
{
195
	int i, j, button_id;
196
197
 
198
199
 
200
		for (j=0;j
201
		{
202
			button_id=blocks_matrix[i*BLOCKS_NUM+j];
203
3587 fedesco 204
 
2794 leency 205
3587 fedesco 206
 
2794 leency 207
			if (i>0) && (blocks_matrix[i-1*BLOCKS_NUM+j]==button_id) return 0;
208
			if (j
209
			if (i
210
		}
211
	return 2;
3587 fedesco 212
}
2794 leency 213
214
 
215
 
216
{
217
	char rezult[15];
218
	int i;
219
	int TEXT_Y=BLOCK_SIZE*BLOCKS_NUM+14;
220
	int TEXT_X=TEXT_Y/2+48; //130;
221
222
 
223
3587 fedesco 224
 
225
		if (blocks_matrix[i]<>DELETED_BLOCK) BLOCKS_LEFT++;
226
227
 
2800 leency 228
	WriteText(TEXT_X,TEXT_Y,0x80,sc.work_text,IntToStr(BLOCKS_LEFT),0);
2821 leency 229
230
 
2794 leency 231
	{
232
		copystr(RESULT_TEXT, #rezult);
7984 leency 233
		copystr(IntToStr(BLOCKS_LEFT), #rezult+strlen(#rezult));
2794 leency 234
		if (check_for_end()==1) copystr("Epic WIN!!1", #rezult);
235
		DrawFlatButton(BLOCK_SIZE*BLOCKS_NUM/2-70, BLOCK_SIZE*BLOCKS_NUM/2-20, 140, 40, 3, #rezult);
3776 leency 236
	}
2794 leency 237
}
238
239
 
240
 
241
{
242
	int i;
243
244
 
245
	//чтобы отметить квадратики в процессе заливки и DELETED_BLOCK  для их удаления
246
	for (i=0;i
7984 leency 247
		blocks_matrix[i] = random(5);
2794 leency 248
	}
7984 leency 249
	DeleteButton(3);
3776 leency 250
}
2794 leency 251
252
 
253
 
254
{
255
	int i, j;
256
	int current_id;
257
3587 fedesco 258
 
2794 leency 259
		for (j=0;j
260
		{
261
			current_id = i*BLOCKS_NUM+j;
262
			DeleteButton(current_id+100);
263
			if (blocks_matrix[current_id]==DELETED_BLOCK)
264
			{
265
				DrawBar(j*BLOCK_SIZE,i*BLOCK_SIZE, BLOCK_SIZE,BLOCK_SIZE, 0xB2B4BF);
266
			}
267
			else
268
			{
269
				DefineButton(j*BLOCK_SIZE,i*BLOCK_SIZE,BLOCK_SIZE-1,BLOCK_SIZE-1, current_id+100+BT_HIDE,0);
270
				PutImage(blocks_matrix[current_id]*1323+#block,21,21,j*BLOCK_SIZE,i*BLOCK_SIZE);
6167 leency 271
			}
2794 leency 272
		}
273
}
274
275
 
276
 
277
{
278
	DrawRegion_3D(x,y,width,height,sc.work_graph,sc.work_graph);
279
	DrawRegion_3D(x+1,y+1,width-2,height-2,0xFFFFFF,sc.work);
280
	DrawBar(x+2,y+2,width-3,height-3,sc.work);
281
	IF (id)	DefineButton(x,y,width,height,id+BT_HIDE,sc.work);
282
	WriteText(-strlen(text)*6+width/2+x+1,height/2-3+y,0x80,sc.work_text,text,0);
283
}
284
285
 
3587 fedesco 286
>