Rev 1006 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1006 | Rev 1768 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | Just Clicks v0.76 |
2 | Just Clicks v0.76 |
3 | Copyright (C) 2008 Leency |
3 | Copyright (C) 2008 Leency |
4 | Clickomania v0.3 |
4 | Clickomania v0.3 |
5 | Copyright (C) 2005 «¥ªá ¤à ã訪®¢ aka Olaf |
5 | Copyright (C) 2005 «¥ªá ¤à ã訪®¢ aka Olaf |
6 | Compiled by C--Sphinx v0.239 b26 |
6 | Compiled by C--Sphinx v0.239 b26 |
7 | */ |
7 | */ |
8 | 8 | ||
9 | #pragma option meos |
9 | #pragma option meos |
10 | #include "lib\kolibri.h--" |
10 | #include "lib\kolibri.h--" |
11 | #include "lib\random.h--" |
11 | #include "lib\random.h--" |
12 | #include "files\boxes.txt" |
12 | #include "files\boxes.txt" |
13 | #include "files\cups.txt" |
13 | #include "files\cups.txt" |
- | 14 | ||
- | 15 | #ifndef AUTOBUILD |
|
- | 16 | #include "lang.h--" |
|
14 | 17 | #endif |
|
- | 18 | ||
15 | 19 | byte i,j, XX, YY; |
|
16 | byte i,j, XX, YY; |
20 | system_colors sc; |
17 | 21 | ||
18 | struct |
22 | struct |
19 | { |
23 | { |
20 | byte x; |
24 | byte x; |
21 | byte y; |
25 | byte y; |
22 | byte button_id; |
26 | byte button_id; |
23 | byte mark; |
27 | byte mark; |
24 | dword color; |
28 | dword color; |
25 | }matrix[64]; |
29 | }matrix[64]; |
26 | 30 | ||
27 | 31 | ||
28 | void check_n_destroy(byte ID, ID1) |
32 | void check_n_destroy(byte ID, ID1) |
29 | { |
33 | { |
30 | IF (matrix[ID1].color == matrix[ID].color) && (matrix[ID1].mark!=1) |
34 | IF (matrix[ID1].color == matrix[ID].color) && (matrix[ID1].mark!=1) |
31 | { |
35 | { |
32 | matrix[ID1].mark=1; |
36 | matrix[ID1].mark=1; |
33 | destroy_button(ID1); |
37 | destroy_button(ID1); |
34 | } |
38 | } |
35 | } |
39 | } |
36 | 40 | ||
37 | 41 | ||
38 | void destroy_button(byte ID) |
42 | void destroy_button(byte ID) |
39 | { |
43 | { |
40 | check_n_destroy(ID, ID-8); |
44 | check_n_destroy(ID, ID-8); |
41 | check_n_destroy(ID, ID+8); |
45 | check_n_destroy(ID, ID+8); |
42 | IF (ID!=0)&&(ID!=8)&&(ID!=16)&&(ID!=24)&&(ID!=32)&&(ID!=40)&&(ID!=48)&&(ID!=56) |
46 | IF (ID!=0)&&(ID!=8)&&(ID!=16)&&(ID!=24)&&(ID!=32)&&(ID!=40)&&(ID!=48)&&(ID!=56) |
43 | check_n_destroy(ID, ID-1); |
47 | check_n_destroy(ID, ID-1); |
44 | IF (ID!=7)&&(ID!=15)&&(ID!=23)&&(ID!=31)&&(ID!=39)&&(ID!=47)&&(ID!=55)&&(ID!=63) |
48 | IF (ID!=7)&&(ID!=15)&&(ID!=23)&&(ID!=31)&&(ID!=39)&&(ID!=47)&&(ID!=55)&&(ID!=63) |
45 | check_n_destroy(ID, ID+1); |
49 | check_n_destroy(ID, ID+1); |
46 | 50 | ||
47 | IF (matrix[ID].x |
51 | IF (matrix[ID].x |
48 | IF (matrix[ID].y>YY) {YY=matrix[ID].y; IF (matrix[ID].x |
52 | IF (matrix[ID].y>YY) {YY=matrix[ID].y; IF (matrix[ID].x |
49 | } |
53 | } |
50 | 54 | ||
51 | 55 | ||
52 | void shift_bars(byte AA, BB) |
56 | void shift_bars(byte AA, BB) |
53 | byte id_curr,id_next,bz; |
57 | byte id_curr,id_next,bz; |
54 | { |
58 | { |
55 | for (j=AA;j<8;j++) for (i=BB; i>0; i--) |
59 | for (j=AA;j<8;j++) for (i=BB; i>0; i--) |
56 | { |
60 | { |
57 | id_curr=i*8+j; |
61 | id_curr=i*8+j; |
58 | bz=i-1; |
62 | bz=i-1; |
59 | _HH: |
63 | _HH: |
60 | id_next=bz*8+j; |
64 | id_next=bz*8+j; |
61 | IF (matrix[id_curr].mark == 1) |
65 | IF (matrix[id_curr].mark == 1) |
62 | IF (bz>0)&&(matrix[id_next].mark == 1) {bz--; GOTO _HH;} |
66 | IF (bz>0)&&(matrix[id_next].mark == 1) {bz--; GOTO _HH;} |
63 | ELSE IF (matrix[id_next].mark == 0) |
67 | ELSE IF (matrix[id_next].mark == 0) |
64 | { |
68 | { |
65 | matrix[id_curr].color=matrix[id_next].color; |
69 | matrix[id_curr].color=matrix[id_next].color; |
66 | matrix[id_curr].mark=matrix[id_next].mark; |
70 | matrix[id_curr].mark=matrix[id_next].mark; |
67 | matrix[id_next].mark=1; |
71 | matrix[id_next].mark=1; |
68 | } |
72 | } |
69 | } |
73 | } |
70 | } |
74 | } |
71 | 75 | ||
72 | byte check_for_end() |
76 | byte check_for_end() |
73 | { |
77 | { |
74 | byte id_next, id_curr; |
78 | byte id_next, id_curr; |
75 | for (j=0; j<64; j+=8) for (i=0; i<8; i++) |
79 | for (j=0; j<64; j+=8) for (i=0; i<8; i++) |
76 | { |
80 | { |
77 | id_curr=j+i; |
81 | id_curr=j+i; |
78 | id_next=id_curr+1; |
82 | id_next=id_curr+1; |
79 | IF (matrix[id_curr].color==matrix[id_next].color)&&(matrix[id_curr].mark==0)&&(matrix[id_next].mark==0) return 0; |
83 | IF (matrix[id_curr].color==matrix[id_next].color)&&(matrix[id_curr].mark==0)&&(matrix[id_next].mark==0) return 0; |
80 | IF (matrix[id_curr].color==matrix[id_next+7].color)&&(matrix[id_curr].mark==0)&&(matrix[id_next+7].mark==0) return 0; |
84 | IF (matrix[id_curr].color==matrix[id_next+7].color)&&(matrix[id_curr].mark==0)&&(matrix[id_next+7].mark==0) return 0; |
81 | } |
85 | } |
82 | return 1; |
86 | return 1; |
83 | } |
87 | } |
84 | 88 | ||
85 | void move_it() |
89 | void move_it() |
86 | byte but_id, count, x; |
90 | byte but_id, count, x; |
87 | { |
91 | { |
88 | for (x=0;x<8;x++) |
92 | for (x=0;x<8;x++) |
89 | { |
93 | { |
90 | count = 0; |
94 | count = 0; |
91 | FOR (i=0;i<8;i++) IF (matrix[i*8+x].mark==1) count++; |
95 | FOR (i=0;i<8;i++) IF (matrix[i*8+x].mark==1) count++; |
92 | if (count == 8) FOR (i=0;i<8;i++) |
96 | if (count == 8) FOR (i=0;i<8;i++) |
93 | { |
97 | { |
94 | XX=x; |
98 | XX=x; |
95 | WHILE (XX<7) |
99 | WHILE (XX<7) |
96 | { |
100 | { |
97 | but_id=i*8+XX; |
101 | but_id=i*8+XX; |
98 | matrix[but_id].mark=matrix[but_id+1].mark; |
102 | matrix[but_id].mark=matrix[but_id+1].mark; |
99 | matrix[but_id].color=matrix[but_id+1].color; |
103 | matrix[but_id].color=matrix[but_id+1].color; |
100 | IF (XX == 6) matrix[but_id+1].mark=1; |
104 | IF (XX == 6) matrix[but_id+1].mark=1; |
101 | XX++; |
105 | XX++; |
102 | } |
106 | } |
103 | } |
107 | } |
104 | } |
108 | } |
105 | } |
109 | } |
106 | 110 | ||
107 | 111 | ||
108 | void ReDraw_Blocks(byte newgame) |
112 | void ReDraw_Blocks(byte newgame) |
109 | { |
113 | { |
110 | byte num=0, y=22, count_blocks=0, temp[10]; |
114 | byte num=0, y=22, count_blocks=0, temp[10]; |
111 | for (i=0;i<8;i++) |
115 | for (i=0;i<8;i++) |
112 | { |
116 | { |
113 | for (j=0;j<8;j++) |
117 | for (j=0;j<8;j++) |
114 | { |
118 | { |
115 | IF (newgame) |
119 | IF (newgame) |
116 | { |
120 | { |
117 | matrix[num].mark=0; |
121 | matrix[num].mark=0; |
118 | XX=9; YY=0; |
122 | XX=9; YY=0; |
119 | matrix[num].color = random(5)+1; |
123 | matrix[num].color = random(5)+1; |
120 | } |
124 | } |
121 | DeleteButton(i*8+j); |
125 | DeleteButton(i*8+j); |
122 | matrix[num].x=j; |
126 | matrix[num].x=j; |
123 | matrix[num].y=i; |
127 | matrix[num].y=i; |
124 | IF (matrix[num].mark==0) |
128 | IF (matrix[num].mark==0) |
125 | { |
129 | { |
126 | DefineButton(j*21,y-22, 20, 20, num+BT_HIDE, 0); |
130 | DefineButton(j*21,y-22, 20, 20, num+BT_HIDE, 0); |
127 | PutImage(matrix[num].color-1*1323+#img,21,21,j*21,y-22); |
131 | PutImage(matrix[num].color-1*1323+#img,21,21,j*21,y-22); |
- | 132 | } |
|
- | 133 | ELSE |
|
128 | } ELSE DrawBar(j*21,y-22,21,21, 0xB2B4BF); |
134 | DrawBar(j*21,y-22,21,21, 0xB2B4BF); |
129 | num++; |
135 | num++; |
130 | } |
136 | } |
131 | y=y+21; |
137 | y=y+21; |
132 | } |
138 | } |
- | 139 | #ifdef LANG_RUS |
|
133 | DrawBar(90,178,71,8,0xE4DFE1); |
140 | DrawBar(90,178,71,8,sc.work); |
134 | IF (check_for_end()==1) WriteText(90,178,0x80,0,"¥§ã«ìâ â:",10); |
141 | IF (check_for_end()==1) WriteText(90,178,0x80,sc.work_text,"¥§ã«ìâ â:",10); |
135 | ELSE WriteText(96,178,0x80,0,"áâ «®áì:",10); |
142 | ELSE WriteText(96,178,0x80,sc.work_text,"áâ «®áì:",10); |
- | 143 | #else |
|
- | 144 | DrawBar(108,178,60,8,sc.work); |
|
- | 145 | IF (check_for_end()==1) WriteText(108,178,0x80,sc.work_text,"Result:",10); |
|
- | 146 | ELSE WriteText(108,178,0x80,sc.work_text,"Blocks:",10); |
|
- | 147 | #endif |
|
136 | FOR (i=0;i<8;i++) FOR (j=0;j<8;j++) IF (matrix[j*8+i].mark==0) count_blocks++; |
148 | FOR (i=0;i<8;i++) FOR (j=0;j<8;j++) IF (matrix[j*8+i].mark==0) count_blocks++; |
137 | WriteNumber(150,178,0x80,0,count_blocks); |
149 | WriteNumber(150,178,0x80,sc.work_text,count_blocks); |
138 | // |
150 | // |
139 | if (check_for_end()==1) && (count_blocks<8) |
151 | if (check_for_end()==1) && (count_blocks<8) |
140 | { |
152 | { |
141 | DrawFlatButton(21,42,125,62,0,0xE4DFE1,""); |
153 | DrawFlatButton(); |
- | 154 | #ifdef LANG_RUS |
|
142 | IF (count_blocks==0) copystr(" ãçè¥ ¢á¥å!", #temp); |
155 | IF (count_blocks==0) copystr(" ãçè¥ ¢á¥å!", #temp); |
143 | IF (count_blocks==1) copystr(" ४à á®", #temp); |
156 | IF (count_blocks==1) copystr(" ४à á®", #temp); |
144 | IF (count_blocks==2) copystr("ç¥ì å®à®è®!", #temp); |
157 | IF (count_blocks==2) copystr("ç¥ì å®à®è®!", #temp); |
- | 158 | #else |
|
- | 159 | IF (count_blocks==0) copystr("The best!", #temp); |
|
- | 160 | IF (count_blocks==1) copystr("Wonderful", #temp); |
|
- | 161 | IF (count_blocks==2) copystr("Very good", #temp); |
|
- | 162 | #endif |
|
145 | IF (count_blocks>=3) //¡ £!!! |
163 | IF (count_blocks>=3) //¡ £!!! |
146 | { |
164 | { |
- | 165 | #ifdef LANG_RUS |
|
147 | copystr(" ¥¯«®å®", #temp); |
166 | copystr(" ¥¯«®å®", #temp); |
- | 167 | #else |
|
- | 168 | copystr(" Not bed", #temp); |
|
- | 169 | #endif |
|
148 | count_blocks=3; |
170 | count_blocks=3; |
149 | } |
171 | } |
150 | PutImage(count_blocks*42*37*3+#cups,42,37,63,48); |
172 | PutImage(count_blocks*4662+#cups,42,37,63,48); |
- | 173 | #ifdef LANG_RUS |
|
151 | WriteText(46,91,0x80,0x0,#temp,0); |
174 | WriteText(46,91,0x80,0x0,#temp,0); |
- | 175 | #else |
|
- | 176 | WriteText(58,91,0x80,0x0,#temp,0); |
|
- | 177 | #endif |
|
152 | } |
178 | } |
153 | } |
179 | } |
154 | 180 | ||
155 | 181 | ||
156 | void main() |
182 | void main() |
157 | { byte id, skin_width; |
183 | { byte id; |
158 | randomize(); |
184 | //randomize(); |
159 | ReDraw_Blocks(1); |
185 | ReDraw_Blocks(1); |
160 | loop() |
186 | loop() |
161 | { |
187 | { |
162 | switch(WaitEvent()) |
188 | switch(WaitEvent()) |
163 | { |
189 | { |
164 | CASE evKey: |
190 | CASE evKey: |
165 | IF (GetKey()==051) ReDraw_Blocks(1); //New game |
191 | IF (GetKey()==051) ReDraw_Blocks(1); //New game |
166 | break; |
192 | break; |
167 | CASE evButton: |
193 | CASE evButton: |
168 | id=GetButtonID(); |
194 | id=GetButtonID(); |
169 | IF (id==255) ExitProcess(); |
195 | IF (id==255) ExitProcess(); |
170 | IF (id==254) ReDraw_Blocks(1); //New game |
196 | IF (id==254) ReDraw_Blocks(1); //New game |
171 | IF (id<65) //Color Button |
197 | IF (id<65) //Color Button |
172 | { |
198 | { |
173 | destroy_button(id); |
199 | destroy_button(id); |
174 | IF (XX!=9) |
200 | IF (XX!=9) |
175 | { |
201 | { |
176 | shift_bars(XX,YY); |
202 | shift_bars(XX,YY); |
177 | IF (YY==7) {move_it();move_it();} |
203 | IF (YY==7) {move_it();move_it();} |
178 | XX=9; |
204 | XX=9; |
179 | YY=0; |
205 | YY=0; |
180 | ReDraw_Blocks(0); |
206 | ReDraw_Blocks(0); |
181 | } |
207 | } |
182 | } |
208 | } |
183 | break; |
209 | break; |
184 | case evReDraw: |
210 | case evReDraw: |
185 | WindowRedrawStatus(1); |
211 | WindowRedrawStatus(1); |
186 | skin_width = GetSkinWidth(); |
- | |
187 | DefineAndDrawWindow(400,276,177,201+skin_width,0x74,0x10B2B4BF,0,0,"Just Clicks v0.76"); |
212 | DefineAndDrawWindow(400,276,177,201+GetSkinWidth(),0x74,0x10B2B4BF,0,0,"Just Clicks v0.77"); |
188 | DefineButton(150,2-skin_width,18,18,255+BT_HIDE+BT_NOFRAME,0x0866CC00); |
- | |
189 | DrawBar(0,168,168,29,0xE4DFE1); |
- | |
190 | //DrawFlatButton(9,172,84,19,254,0xE4DFE1,"New game (F2)"); |
- | |
191 | DrawFlatButton(4,172,80,19,254,0xE4DFE1," ®¢® (F2)"); |
- | |
192 | ReDraw_Blocks(0); |
- | |
193 | WindowRedrawStatus(2); |
213 | WindowRedrawStatus(2); |
- | 214 | sc.get(); |
|
- | 215 | DefineButton(150,-18,18,18,255+BT_HIDE+BT_NOFRAME,0); //ª®¯®çª § ªàëâ¨ï :] |
|
- | 216 | DrawBar(0,168,168,29,sc.work); //¯ ¥«ìª ᨧã |
|
- | 217 | #ifdef LANG_RUS |
|
- | 218 | DefineButton(9,172,76,19,254,sc.work_button); |
|
- | 219 | WriteText(16,178,0x80,sc.work_button_text," ®¢® (F2)",0); |
|
- | 220 | #else |
|
- | 221 | DefineButton(9,172,86,19,254,sc.work_button); |
|
- | 222 | WriteText(15,178,0x80,sc.work_button_text,"New game (F2)",0); |
|
- | 223 | #endif |
|
- | 224 | ReDraw_Blocks(0); |
|
- | 225 | } |
|
194 | } |
226 | } |
195 | } |
227 | } |
- | 228 | ||
- | 229 | ||
- | 230 | void DrawFlatButton() |
|
- | 231 | { |
|
- | 232 | DrawBar(21,42,125,1,0x94AECE); //¯®«®á £®à ᢥàåã |
|
- | 233 | DrawBar(21,104,125,1,0x94AECE); //¯®«®á £®à ᨧã |
|
- | 234 | DrawBar(21,42,1,62,0x94AECE); //¯®«®á ¢¥àâ á«¥¢ |
|
- | 235 | DrawBar(146,42,1,63,0x94AECE); //¯®«®á ¢¥àâ á¯à ¢ |
|
- | 236 | DrawBar(22,43,124,1,0xFFFFFF); //¯®«®á £®à ¡¥« ï |
|
- | 237 | DrawBar(22,103,123,1,0xC7C7C7); //â¥ì ¢¥àâ |
|
- | 238 | DrawBar(22,43,1,61,0xFFFFFF); //¯®«®á ¢¥àâ ¡¥« ï |
|
- | 239 | DrawBar(145,44,1,60,0xC7C7C7); //â¥ì ¢¥àâ |
|
- | 240 | DrawBar(23,44,122,59,0xE4DFE1); //§ «¨¢ª |
|
196 | } |
241 | } |
197 | 242 | ||
198 | stop:65)>8) |
243 | stop:65)>8) |
199 | >8;j++)>8;i++)>8;j++) |
244 | >8;j++)>8;i++)>8;j++) |
200 | >8;i++) |
245 | >8;i++) |
201 | >7) |
246 | >7) |
202 | >8;i++) |
247 | >8;i++) |
203 | >8;i++)>8;x++) |
248 | >8;i++)>8;x++) |
204 | >8;>64;>8;j++)> |
249 | >8;>64;>8;j++)> |