Rev 1006 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
778 | gluk | 1 | /* |
1006 | leency | 2 | Just Clicks v0.76 |
1003 | leency | 3 | Copyright (C) 2008 Leency |
778 | gluk | 4 | Clickomania v0.3 |
5 | Copyright (C) 2005 Александр Мушиков aka Olaf |
||
6 | Compiled by C--Sphinx v0.239 b26 |
||
7 | */ |
||
8 | |||
9 | #pragma option meos |
||
10 | #include "lib\kolibri.h--" |
||
11 | #include "lib\random.h--" |
||
1003 | leency | 12 | #include "files\boxes.txt" |
13 | #include "files\cups.txt" |
||
1768 | clevermous | 14 | |
15 | #ifndef AUTOBUILD |
||
16 | #include "lang.h--" |
||
17 | #endif |
||
778 | gluk | 18 | |
1003 | leency | 19 | byte i,j, XX, YY; |
1768 | clevermous | 20 | system_colors sc; |
1003 | leency | 21 | |
778 | gluk | 22 | struct |
23 | { |
||
24 | byte x; |
||
25 | byte y; |
||
26 | byte button_id; |
||
27 | byte mark; |
||
28 | dword color; |
||
1003 | leency | 29 | }matrix[64]; |
778 | gluk | 30 | |
31 | |||
1006 | leency | 32 | void check_n_destroy(byte ID, ID1) |
33 | { |
||
34 | IF (matrix[ID1].color == matrix[ID].color) && (matrix[ID1].mark!=1) |
||
35 | { |
||
36 | matrix[ID1].mark=1; |
||
37 | destroy_button(ID1); |
||
38 | } |
||
39 | } |
||
778 | gluk | 40 | |
1006 | leency | 41 | |
1003 | leency | 42 | void destroy_button(byte ID) |
778 | gluk | 43 | { |
1006 | leency | 44 | check_n_destroy(ID, ID-8); |
45 | check_n_destroy(ID, ID+8); |
||
46 | IF (ID!=0)&&(ID!=8)&&(ID!=16)&&(ID!=24)&&(ID!=32)&&(ID!=40)&&(ID!=48)&&(ID!=56) |
||
47 | check_n_destroy(ID, ID-1); |
||
48 | IF (ID!=7)&&(ID!=15)&&(ID!=23)&&(ID!=31)&&(ID!=39)&&(ID!=47)&&(ID!=55)&&(ID!=63) |
||
49 | check_n_destroy(ID, ID+1); |
||
50 | |||
1003 | leency | 51 | IF (matrix[ID].x |
52 | IF (matrix[ID].y>YY) {YY=matrix[ID].y; IF (matrix[ID].x |
||
778 | gluk | 53 | } |
54 | |||
1006 | leency | 55 | |
778 | gluk | 56 | void shift_bars(byte AA, BB) |
57 | byte id_curr,id_next,bz; |
||
58 | { |
||
59 | for (j=AA;j<8;j++) for (i=BB; i>0; i--) |
||
60 | { |
||
61 | id_curr=i*8+j; |
||
62 | bz=i-1; |
||
63 | _HH: |
||
64 | id_next=bz*8+j; |
||
65 | IF (matrix[id_curr].mark == 1) |
||
66 | IF (bz>0)&&(matrix[id_next].mark == 1) {bz--; GOTO _HH;} |
||
67 | ELSE IF (matrix[id_next].mark == 0) |
||
68 | { |
||
69 | matrix[id_curr].color=matrix[id_next].color; |
||
70 | matrix[id_curr].mark=matrix[id_next].mark; |
||
71 | matrix[id_next].mark=1; |
||
72 | } |
||
73 | } |
||
74 | } |
||
75 | |||
1003 | leency | 76 | byte check_for_end() |
778 | gluk | 77 | { |
1003 | leency | 78 | byte id_next, id_curr; |
79 | for (j=0; j<64; j+=8) for (i=0; i<8; i++) |
||
778 | gluk | 80 | { |
1003 | leency | 81 | id_curr=j+i; |
82 | id_next=id_curr+1; |
||
83 | IF (matrix[id_curr].color==matrix[id_next].color)&&(matrix[id_curr].mark==0)&&(matrix[id_next].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; |
||
778 | gluk | 85 | } |
86 | return 1; |
||
87 | } |
||
88 | |||
1003 | leency | 89 | void move_it() |
90 | byte but_id, count, x; |
||
778 | gluk | 91 | { |
92 | for (x=0;x<8;x++) |
||
93 | { |
||
94 | count = 0; |
||
95 | FOR (i=0;i<8;i++) IF (matrix[i*8+x].mark==1) count++; |
||
1003 | leency | 96 | if (count == 8) FOR (i=0;i<8;i++) |
778 | gluk | 97 | { |
98 | XX=x; |
||
99 | WHILE (XX<7) |
||
100 | { |
||
1003 | leency | 101 | but_id=i*8+XX; |
102 | matrix[but_id].mark=matrix[but_id+1].mark; |
||
103 | matrix[but_id].color=matrix[but_id+1].color; |
||
104 | IF (XX == 6) matrix[but_id+1].mark=1; |
||
778 | gluk | 105 | XX++; |
106 | } |
||
107 | } |
||
108 | } |
||
109 | } |
||
110 | |||
111 | |||
1003 | leency | 112 | void ReDraw_Blocks(byte newgame) |
778 | gluk | 113 | { |
1003 | leency | 114 | byte num=0, y=22, count_blocks=0, temp[10]; |
778 | gluk | 115 | for (i=0;i<8;i++) |
116 | { |
||
117 | for (j=0;j<8;j++) |
||
118 | { |
||
1003 | leency | 119 | IF (newgame) |
778 | gluk | 120 | { |
121 | matrix[num].mark=0; |
||
122 | XX=9; YY=0; |
||
123 | matrix[num].color = random(5)+1; |
||
124 | } |
||
1003 | leency | 125 | DeleteButton(i*8+j); |
778 | gluk | 126 | matrix[num].x=j; |
127 | matrix[num].y=i; |
||
128 | IF (matrix[num].mark==0) |
||
129 | { |
||
1006 | leency | 130 | DefineButton(j*21,y-22, 20, 20, num+BT_HIDE, 0); |
131 | PutImage(matrix[num].color-1*1323+#img,21,21,j*21,y-22); |
||
1768 | clevermous | 132 | } |
133 | ELSE |
||
134 | DrawBar(j*21,y-22,21,21, 0xB2B4BF); |
||
778 | gluk | 135 | num++; |
136 | } |
||
137 | y=y+21; |
||
138 | } |
||
1768 | clevermous | 139 | #ifdef LANG_RUS |
140 | DrawBar(90,178,71,8,sc.work); |
||
141 | IF (check_for_end()==1) WriteText(90,178,0x80,sc.work_text,"Результат:",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 |
||
1003 | leency | 148 | FOR (i=0;i<8;i++) FOR (j=0;j<8;j++) IF (matrix[j*8+i].mark==0) count_blocks++; |
1768 | clevermous | 149 | WriteNumber(150,178,0x80,sc.work_text,count_blocks); |
1003 | leency | 150 | // |
151 | if (check_for_end()==1) && (count_blocks<8) |
||
152 | { |
||
1768 | clevermous | 153 | DrawFlatButton(); |
154 | #ifdef LANG_RUS |
||
1003 | leency | 155 | IF (count_blocks==0) copystr(" Лучше всех!", #temp); |
156 | IF (count_blocks==1) copystr(" Прекрасно", #temp); |
||
157 | IF (count_blocks==2) copystr("Очень хорошо!", #temp); |
||
1768 | clevermous | 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 |
||
1003 | leency | 163 | IF (count_blocks>=3) //баг!!! |
164 | { |
||
1768 | clevermous | 165 | #ifdef LANG_RUS |
1003 | leency | 166 | copystr(" Неплохо", #temp); |
1768 | clevermous | 167 | #else |
168 | copystr(" Not bed", #temp); |
||
169 | #endif |
||
1003 | leency | 170 | count_blocks=3; |
171 | } |
||
1768 | clevermous | 172 | PutImage(count_blocks*4662+#cups,42,37,63,48); |
173 | #ifdef LANG_RUS |
||
1006 | leency | 174 | WriteText(46,91,0x80,0x0,#temp,0); |
1768 | clevermous | 175 | #else |
176 | WriteText(58,91,0x80,0x0,#temp,0); |
||
177 | #endif |
||
1003 | leency | 178 | } |
778 | gluk | 179 | } |
180 | |||
1003 | leency | 181 | |
182 | void main() |
||
1768 | clevermous | 183 | { byte id; |
184 | //randomize(); |
||
1003 | leency | 185 | ReDraw_Blocks(1); |
186 | loop() |
||
187 | { |
||
188 | switch(WaitEvent()) |
||
189 | { |
||
1006 | leency | 190 | CASE evKey: |
191 | IF (GetKey()==051) ReDraw_Blocks(1); //New game |
||
192 | break; |
||
1003 | leency | 193 | CASE evButton: |
194 | id=GetButtonID(); |
||
195 | IF (id==255) ExitProcess(); |
||
1006 | leency | 196 | IF (id==254) ReDraw_Blocks(1); //New game |
197 | IF (id<65) //Color Button |
||
198 | { |
||
199 | destroy_button(id); |
||
200 | IF (XX!=9) |
||
201 | { |
||
202 | shift_bars(XX,YY); |
||
203 | IF (YY==7) {move_it();move_it();} |
||
204 | XX=9; |
||
205 | YY=0; |
||
206 | ReDraw_Blocks(0); |
||
207 | } |
||
208 | } |
||
209 | break; |
||
1003 | leency | 210 | case evReDraw: |
211 | WindowRedrawStatus(1); |
||
1768 | clevermous | 212 | DefineAndDrawWindow(400,276,177,201+GetSkinWidth(),0x74,0x10B2B4BF,0,0,"Just Clicks v0.77"); |
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 |
||
1003 | leency | 224 | ReDraw_Blocks(0); |
225 | } |
||
226 | } |
||
778 | gluk | 227 | } |
228 | |||
1768 | clevermous | 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); //заливка |
||
241 | } |
||
242 | |||
778 | gluk | 243 | stop:65)>8) |