Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1002 → Rev 1003

/programs/games/clicks/trunk/clicks.c--
1,6 → 1,6
/*
Just Clicks v0.6
Copyright (C) 2008 Leency & Veliant
Just Clicks v0.75
Copyright (C) 2008 Leency
Clickomania v0.3
Copyright (C) 2005 €«¥ªá ­¤à Œã訪®¢ aka Olaf
Compiled by C--Sphinx v0.239 b26
7,13 → 7,14
*/
 
#pragma option meos
#jumptomain NONE
#include "lib\kolibri.h--"
#include "lib\random.h--"
#include "img.txt"
#include "files\boxes.txt"
#include "files\cups.txt"
 
byte i, need_redraw, XX, YY;
 
byte i,j, XX, YY;
 
struct
{
byte x;
21,32 → 22,32
byte button_id;
byte mark;
dword color;
}matrix[8*8];
}matrix[64];
 
 
 
void destroy_button(dword ID)
void destroy_button(byte ID)
{
IF ((matrix[ID-8].color == matrix[ID].color)&&(matrix[ID-8].mark!=1)){
IF (matrix[ID-8].color == matrix[ID].color) && (matrix[ID-8].mark!=1)
{
matrix[ID-8].mark=1;
need_redraw=1;
destroy_button(ID-8);
}
IF ((matrix[ID+8].color == matrix[ID].color)&&(matrix[ID+8].mark!=1)){
IF (matrix[ID+8].color == matrix[ID].color) && (matrix[ID+8].mark!=1)
{
matrix[ID+8].mark=1;
need_redraw=1;
destroy_button(ID+8);
}
IF ((ID!=0)&&(ID!=8)&&(ID!=16)&&(ID!=24)&&(ID!=32)&&(ID!=40)&&(ID!=48)&&(ID!=56))
IF ((matrix[ID-1].color == matrix[ID].color)&&(matrix[ID-1].mark!=1)){
IF (ID!=0)&&(ID!=8)&&(ID!=16)&&(ID!=24)&&(ID!=32)&&(ID!=40)&&(ID!=48)&&(ID!=56)
&& (matrix[ID-1].color == matrix[ID].color) && (matrix[ID-1].mark!=1)
{
matrix[ID-1].mark=1;
need_redraw=1;
destroy_button(ID-1);
}
IF ((ID!=7)&&(ID!=15)&&(ID!=23)&&(ID!=31)&&(ID!=39)&&(ID!=47)&&(ID!=55)&&(ID!=63))
IF ((matrix[ID+1].color == matrix[ID].color)&&(matrix[ID+1].mark!=1)){
IF (ID!=7)&&(ID!=15)&&(ID!=23)&&(ID!=31)&&(ID!=39)&&(ID!=47)&&(ID!=55)&&(ID!=63)
&& (matrix[ID+1].color == matrix[ID].color) && (matrix[ID+1].mark!=1)
{
matrix[ID+1].mark=1;
need_redraw=1;
destroy_button(ID+1);
}
IF (matrix[ID].x<XX){XX=matrix[ID].x; IF (matrix[ID].y>YY) YY=matrix[ID].y;}
73,46 → 74,35
}
}
 
byte count_blocks()
{
byte kol_vo=0;
FOR (i=0;i<8;i++) FOR (j=0;j<8;j++) IF (matrix[j*8+i].mark==0) kol_vo++;
return kol_vo;
}
 
 
byte check_for_end ()
byte id_next_two, id_next_one, crr;
{
for (j=0; j<8; j++) for (i=0; i<8; i++)
byte id_next, id_curr;
for (j=0; j<64; j+=8) for (i=0; i<8; i++)
{
crr=j*8+i;
id_next_one=crr+1;
id_next_two=j+1*8+i;
IF (matrix[crr].color==matrix[id_next_one].color)&&(matrix[crr].mark==0)&&(matrix[id_next_one].mark==0) return 0;
IF (matrix[crr].color==matrix[id_next_two].color)&&(matrix[crr].mark==0)&&(matrix[id_next_two].mark==0) return 0;
id_curr=j+i;
id_next=id_curr+1;
IF (matrix[id_curr].color==matrix[id_next].color)&&(matrix[id_curr].mark==0)&&(matrix[id_next].mark==0) return 0;
IF (matrix[id_curr].color==matrix[id_next+7].color)&&(matrix[id_curr].mark==0)&&(matrix[id_next+7].mark==0) return 0;
}
return 1;
}
 
void move_it ()
byte but_id_curr,but_id_next, count, x;
byte but_id, count, x;
{
for (x=0;x<8;x++)
{
count = 0;
FOR (i=0;i<8;i++) IF (matrix[i*8+x].mark==1) count++;
if (count == 8) for (i=0;i<8;i++)
if (count == 8) FOR (i=0;i<8;i++)
{
XX=x;
WHILE (XX<7)
{
but_id_curr=i*8+XX;
but_id_next=i*8+XX+1;
matrix[but_id_curr].mark=matrix[but_id_next].mark;
matrix[but_id_curr].color=matrix[but_id_next].color;
matrix[but_id_next].mark=1;
IF (XX+1 == 7) matrix[but_id_next].mark=1;
but_id=i*8+XX;
matrix[but_id].mark=matrix[but_id+1].mark;
matrix[but_id].color=matrix[but_id+1].color;
IF (XX == 6) matrix[but_id+1].mark=1;
XX++;
}
}
120,84 → 110,92
}
 
 
void main()
{ dword id;
randomize();
skin_width = GetSkinWidth();
ReDraw_Blocks(1);
loop()
void ReDraw_Blocks(byte newgame)
{
switch(WaitEvent())
{
CASE evButton:
id=GetButtonID();
IF (id==600) {ExitProcess(); break;}
ELSE IF (id==500) {ReDraw_Blocks(1);break;}
ELSE {
destroy_button(id);
IF (XX!=9)&&(need_redraw==1)
{
shift_bars(XX,YY);
IF (YY == 7) {move_it();move_it();}
XX=9;
YY=0;
ReDraw_Blocks(0);
}
break;
}
case evKey: IF (GetKey()==051) ReDraw_Blocks(1); break;//New game
case evReDraw: draw_window(); break;
}
}
ExitProcess();
}
 
void ReDraw_Blocks(dword newgame)
{
dword num=0, y;
y=skin_width;
byte num=0, y=22, count_blocks=0, temp[10];
for (i=0;i<8;i++)
{
for (j=0;j<8;j++)
{
IF (newgame == 1)
IF (newgame)
{
matrix[num].mark=0;
XX=9; YY=0;
matrix[num].color = random(5)+1;
}
DefineButton(1,1,1,1,i*8+j+BT_DEL,1);
DeleteButton(i*8+j);
matrix[num].x=j;
matrix[num].y=i;
IF (matrix[num].mark==0)
{
DefineButton(j*21+5,y-22, 20, 20, num+BT_HIDE, matrix[num].color);
PutImage(matrix[num].color-1*21*21*3+#img,21,21,j*21+5,y-22);
DefineButton(j*21+5,y-22, 20, 20, num+BT_HIDE, 0);
PutImage(matrix[num].color-1*1323+#img,21,21,j*21+5,y-22);
} ELSE DrawBar(j*21+5,y-22,21,21, 0xB2B4BF);
num++;
}
y=y+21;
}
EDI = 0x00E4DFE1; //梥⠯ ­¥«¨
IF (check_for_end()==1) WriteText(95,178,0xC0,0x000000,"¥§ã«ìâ â:",10); //184
ELSE WriteText(95,178,0xC0,0x000000," Žáâ «®áì:",10);
WriteText(155,178,0xC0,0x000000,IntToStr(count_blocks()),0); //«®ª®¢ ®áâ «®áì
IF (count_blocks()<10) DrawBar(161,178,6,8,0xE4DFE1);
need_redraw=0;
DrawBar(95,178,71,8,0xE4DFE1);
IF (check_for_end()==1) WriteText(95,178,0x80,0,"¥§ã«ìâ â:",10);
ELSE WriteText(101,178,0x80,0,"Žáâ «®áì:",10);
FOR (i=0;i<8;i++) FOR (j=0;j<8;j++) IF (matrix[j*8+i].mark==0) count_blocks++;
WriteText(155,178,0x80,0,IntToStr(count_blocks),0);
//
if (check_for_end()==1) && (count_blocks<8)
{
DrawFlatButton(26,42,125,62,0,0xE4DFE1,"");
IF (count_blocks==0) copystr(" ‹ãçè¥ ¢á¥å!", #temp);
IF (count_blocks==1) copystr(" à¥ªà á­®", #temp);
IF (count_blocks==2) copystr("Žç¥­ì å®à®è®!", #temp);
IF (count_blocks>=3) //¡ £!!!
{
copystr(" ¥¯«®å®", #temp);
count_blocks=3;
}
PutImage(count_blocks*42*37*3+#cups,42,37,68,48);
WriteText(51,91,0x80,0x0,#temp,0);
}
}
 
void draw_window()
 
void main()
{ byte id;
randomize();
ReDraw_Blocks(1);
loop()
{
switch(WaitEvent())
{
CASE evKey: IF (GetKey()==051) ReDraw_Blocks(1); break; //New game
CASE evButton:
id=GetButtonID();
IF (id==255) ExitProcess();
IF (id==254) {ReDraw_Blocks(1); break;} //New game
IF (id<65) IF (check_for_end()<>1)
{ //if Button
destroy_button(id);
IF (XX!=9)
{
shift_bars(XX,YY);
IF (YY == 7) {move_it();move_it();}
XX=9;
YY=0;
ReDraw_Blocks(0);
}
break;
}
case evReDraw:
WindowRedrawStatus(1);
DefineAndDrawWindow(300,176,177,201+skin_width,0x04,0x00B2B4BF,0,0,0);
DefineButton(155,2-skin_width,18,18,600+BT_HIDE+BT_NOFRAME,0x0866CC00); //ª­®¯ª  § ªàëâ¨ï
DrawTitle("Just Clicks v0.6 L&V");
DrawBar(5,168,168,29,0xE4DFE1); //¯®«¥ á­¨§ã
DrawFlatButton(9,172,84,19,500,0xE4DFE1); //New E4DFE1
WriteText(14,178,0x80,0,"New game (F2) ",14);
//WriteText(95,172,0x80,0," “஢¥­ì:01",10); //“஢¥­ì
skin_width = GetSkinWidth();
DefineAndDrawWindow(400,276,177,201+skin_width,0x44,0x10B2B4BF,0,0,"Just Clicks v0.75");
//DefineButton(155,2-skin_width,18,18,255+BT_HIDE+BT_NOFRAME,0x0866CC00);
DrawBar(5,168,168,29,0xE4DFE1);
//DrawFlatButton(9,172,84,19,254,0xE4DFE1,"New game (F2)");
DrawFlatButton(9,172,80,19,254,0xE4DFE1,"‡ ­®¢® (F2)");
ReDraw_Blocks(0);
WindowRedrawStatus(2);
}
}
}
 
stop: