Rev 1003 | 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" |
||
778 | gluk | 14 | |
15 | |||
1003 | leency | 16 | byte i,j, XX, YY; |
17 | |||
778 | gluk | 18 | struct |
19 | { |
||
20 | byte x; |
||
21 | byte y; |
||
22 | byte button_id; |
||
23 | byte mark; |
||
24 | dword color; |
||
1003 | leency | 25 | }matrix[64]; |
778 | gluk | 26 | |
27 | |||
1006 | leency | 28 | void check_n_destroy(byte ID, ID1) |
29 | { |
||
30 | IF (matrix[ID1].color == matrix[ID].color) && (matrix[ID1].mark!=1) |
||
31 | { |
||
32 | matrix[ID1].mark=1; |
||
33 | destroy_button(ID1); |
||
34 | } |
||
35 | } |
||
778 | gluk | 36 | |
1006 | leency | 37 | |
1003 | leency | 38 | void destroy_button(byte ID) |
778 | gluk | 39 | { |
1006 | leency | 40 | check_n_destroy(ID, ID-8); |
41 | check_n_destroy(ID, ID+8); |
||
42 | IF (ID!=0)&&(ID!=8)&&(ID!=16)&&(ID!=24)&&(ID!=32)&&(ID!=40)&&(ID!=48)&&(ID!=56) |
||
43 | check_n_destroy(ID, ID-1); |
||
44 | IF (ID!=7)&&(ID!=15)&&(ID!=23)&&(ID!=31)&&(ID!=39)&&(ID!=47)&&(ID!=55)&&(ID!=63) |
||
45 | check_n_destroy(ID, ID+1); |
||
46 | |||
1003 | leency | 47 | IF (matrix[ID].x |
48 | IF (matrix[ID].y>YY) {YY=matrix[ID].y; IF (matrix[ID].x |
||
778 | gluk | 49 | } |
50 | |||
1006 | leency | 51 | |
778 | gluk | 52 | void shift_bars(byte AA, BB) |
53 | byte id_curr,id_next,bz; |
||
54 | { |
||
55 | for (j=AA;j<8;j++) for (i=BB; i>0; i--) |
||
56 | { |
||
57 | id_curr=i*8+j; |
||
58 | bz=i-1; |
||
59 | _HH: |
||
60 | id_next=bz*8+j; |
||
61 | IF (matrix[id_curr].mark == 1) |
||
62 | IF (bz>0)&&(matrix[id_next].mark == 1) {bz--; GOTO _HH;} |
||
63 | ELSE IF (matrix[id_next].mark == 0) |
||
64 | { |
||
65 | matrix[id_curr].color=matrix[id_next].color; |
||
66 | matrix[id_curr].mark=matrix[id_next].mark; |
||
67 | matrix[id_next].mark=1; |
||
68 | } |
||
69 | } |
||
70 | } |
||
71 | |||
1003 | leency | 72 | byte check_for_end() |
778 | gluk | 73 | { |
1003 | leency | 74 | byte id_next, id_curr; |
75 | for (j=0; j<64; j+=8) for (i=0; i<8; i++) |
||
778 | gluk | 76 | { |
1003 | leency | 77 | id_curr=j+i; |
78 | 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; |
||
80 | 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 | 81 | } |
82 | return 1; |
||
83 | } |
||
84 | |||
1003 | leency | 85 | void move_it() |
86 | byte but_id, count, x; |
||
778 | gluk | 87 | { |
88 | for (x=0;x<8;x++) |
||
89 | { |
||
90 | count = 0; |
||
91 | FOR (i=0;i<8;i++) IF (matrix[i*8+x].mark==1) count++; |
||
1003 | leency | 92 | if (count == 8) FOR (i=0;i<8;i++) |
778 | gluk | 93 | { |
94 | XX=x; |
||
95 | WHILE (XX<7) |
||
96 | { |
||
1003 | leency | 97 | but_id=i*8+XX; |
98 | matrix[but_id].mark=matrix[but_id+1].mark; |
||
99 | matrix[but_id].color=matrix[but_id+1].color; |
||
100 | IF (XX == 6) matrix[but_id+1].mark=1; |
||
778 | gluk | 101 | XX++; |
102 | } |
||
103 | } |
||
104 | } |
||
105 | } |
||
106 | |||
107 | |||
1003 | leency | 108 | void ReDraw_Blocks(byte newgame) |
778 | gluk | 109 | { |
1003 | leency | 110 | byte num=0, y=22, count_blocks=0, temp[10]; |
778 | gluk | 111 | for (i=0;i<8;i++) |
112 | { |
||
113 | for (j=0;j<8;j++) |
||
114 | { |
||
1003 | leency | 115 | IF (newgame) |
778 | gluk | 116 | { |
117 | matrix[num].mark=0; |
||
118 | XX=9; YY=0; |
||
119 | matrix[num].color = random(5)+1; |
||
120 | } |
||
1003 | leency | 121 | DeleteButton(i*8+j); |
778 | gluk | 122 | matrix[num].x=j; |
123 | matrix[num].y=i; |
||
124 | IF (matrix[num].mark==0) |
||
125 | { |
||
1006 | leency | 126 | 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); |
||
128 | } ELSE DrawBar(j*21,y-22,21,21, 0xB2B4BF); |
||
778 | gluk | 129 | num++; |
130 | } |
||
131 | y=y+21; |
||
132 | } |
||
1006 | leency | 133 | DrawBar(90,178,71,8,0xE4DFE1); |
134 | IF (check_for_end()==1) WriteText(90,178,0x80,0,"Результат:",10); |
||
135 | ELSE WriteText(96,178,0x80,0,"Осталось:",10); |
||
1003 | leency | 136 | FOR (i=0;i<8;i++) FOR (j=0;j<8;j++) IF (matrix[j*8+i].mark==0) count_blocks++; |
1006 | leency | 137 | WriteNumber(150,178,0x80,0,count_blocks); |
1003 | leency | 138 | // |
139 | if (check_for_end()==1) && (count_blocks<8) |
||
140 | { |
||
1006 | leency | 141 | DrawFlatButton(21,42,125,62,0,0xE4DFE1,""); |
1003 | leency | 142 | IF (count_blocks==0) copystr(" Лучше всех!", #temp); |
143 | IF (count_blocks==1) copystr(" Прекрасно", #temp); |
||
144 | IF (count_blocks==2) copystr("Очень хорошо!", #temp); |
||
145 | IF (count_blocks>=3) //баг!!! |
||
146 | { |
||
147 | copystr(" Неплохо", #temp); |
||
148 | count_blocks=3; |
||
149 | } |
||
1006 | leency | 150 | PutImage(count_blocks*42*37*3+#cups,42,37,63,48); |
151 | WriteText(46,91,0x80,0x0,#temp,0); |
||
1003 | leency | 152 | } |
778 | gluk | 153 | } |
154 | |||
1003 | leency | 155 | |
156 | void main() |
||
1006 | leency | 157 | { byte id, skin_width; |
1003 | leency | 158 | randomize(); |
159 | ReDraw_Blocks(1); |
||
160 | loop() |
||
161 | { |
||
162 | switch(WaitEvent()) |
||
163 | { |
||
1006 | leency | 164 | CASE evKey: |
165 | IF (GetKey()==051) ReDraw_Blocks(1); //New game |
||
166 | break; |
||
1003 | leency | 167 | CASE evButton: |
168 | id=GetButtonID(); |
||
169 | IF (id==255) ExitProcess(); |
||
1006 | leency | 170 | IF (id==254) ReDraw_Blocks(1); //New game |
171 | IF (id<65) //Color Button |
||
172 | { |
||
173 | destroy_button(id); |
||
174 | IF (XX!=9) |
||
175 | { |
||
176 | shift_bars(XX,YY); |
||
177 | IF (YY==7) {move_it();move_it();} |
||
178 | XX=9; |
||
179 | YY=0; |
||
180 | ReDraw_Blocks(0); |
||
181 | } |
||
182 | } |
||
183 | break; |
||
1003 | leency | 184 | case evReDraw: |
185 | WindowRedrawStatus(1); |
||
186 | skin_width = GetSkinWidth(); |
||
1006 | leency | 187 | DefineAndDrawWindow(400,276,177,201+skin_width,0x74,0x10B2B4BF,0,0,"Just Clicks v0.76"); |
188 | DefineButton(150,2-skin_width,18,18,255+BT_HIDE+BT_NOFRAME,0x0866CC00); |
||
189 | DrawBar(0,168,168,29,0xE4DFE1); |
||
1003 | leency | 190 | //DrawFlatButton(9,172,84,19,254,0xE4DFE1,"New game (F2)"); |
1006 | leency | 191 | DrawFlatButton(4,172,80,19,254,0xE4DFE1,"Заново (F2)"); |
1003 | leency | 192 | ReDraw_Blocks(0); |
193 | WindowRedrawStatus(2); |
||
194 | } |
||
195 | } |
||
778 | gluk | 196 | } |
197 | |||
198 | stop:65)>8) |