forked from KolibriOS/kolibrios
fe26455cec
git-svn-id: svn://kolibrios.org@6363 a494cfbc-eb01-0410-851d-a64ba20cac60
158 lines
3.0 KiB
Plaintext
158 lines
3.0 KiB
Plaintext
//(C) Artemonische, 2010
|
||
|
||
#pragma option meos
|
||
//#include "..\lib\kolibri.h--" //¯®¤ª«îç ¥¬ ¡¨¡«¨®â¥ªã á KolibriOS API
|
||
#include "kolibri.h--"
|
||
|
||
int find=10;
|
||
struct
|
||
{
|
||
int x;
|
||
int y;
|
||
int button_id;
|
||
int mark;
|
||
int text;
|
||
}box[81];
|
||
|
||
void main()
|
||
{
|
||
int button,tempi,tempj;
|
||
randomize();
|
||
initialization();
|
||
draw_window();
|
||
draw_buttons();
|
||
loop()
|
||
{
|
||
switch(WaitEvent())
|
||
{
|
||
case evButton:
|
||
button=GetButtonID();
|
||
IF (button==1)
|
||
{
|
||
ExitProcess();
|
||
}
|
||
IF (button==582)
|
||
{
|
||
find=10;
|
||
initialization();
|
||
draw_window();
|
||
draw_buttons();
|
||
}
|
||
if (button>500) && (button<582) && (box[button-500].text == find)
|
||
{
|
||
box[button-500].mark=2;
|
||
find++;
|
||
IF (find==91)
|
||
{
|
||
draw_window();
|
||
}
|
||
else
|
||
{
|
||
DeleteButton(button);
|
||
tempi=box[button-500].y*30-30;
|
||
tempj=30*box[button-500].x-16;
|
||
DrawBar(tempi,tempj,30,30,0xDCFFDC);
|
||
DrawBar(70,289,16,8,0xDCFFDC);
|
||
DrawBar(252,289,16,8,0xDCFFDC);
|
||
WriteNumber(70,289,0x80,0,find);
|
||
WriteNumber(252,289,0x80,0,90-find+1);
|
||
}
|
||
}
|
||
BREAK;
|
||
case evKey: //¥á«¨ ¯à®¨§®è«® ¦ ⨥ ª« ¢¨è¨ ª« ¢¨ âãà¥
|
||
IF (GetKey()==051)
|
||
{
|
||
find=10;
|
||
initialization();
|
||
draw_window();
|
||
draw_buttons();
|
||
}
|
||
BREAK;
|
||
case evReDraw:
|
||
draw_window();
|
||
draw_buttons();
|
||
break;
|
||
}
|
||
}
|
||
ExitProcess();
|
||
}
|
||
|
||
void draw_window()
|
||
{
|
||
WindowRedrawStatus(1); // ç «® ¯¥à¥à¨á®¢ª¨ ®ª
|
||
DefineAndDrawWindow(300,176,280,340,0x34,0xDCFFDC,0,0,"FindNumbers v1.1"); //à¨á㥬 ®ª®
|
||
DrawBar(0,13,271,1,0x0CFF0C); //«¨¨ï ᢥàåã
|
||
DrawBar(0,285,271,1,0x0CFF0C);
|
||
DrawBar(0,299,271,1,0x0CFF0C); //«¨¨ï ᨧã
|
||
if (find<=90)
|
||
{
|
||
WriteText(4,4,0x80,0x000000,"‘®¡¥à¨â¥ ¢á¥ ç¨á« ®â 10 ¤® 90 ¯® ¯®à浪ã...");
|
||
WriteText(4,289,0x80,0x000000,"ˆé¥¬ ç¨á«®: ");
|
||
WriteText(162,289,0x80,0x000000,"Žáâ «®áì ©â¨: ");
|
||
WriteNumber(70,289,0x80,0,find);
|
||
WriteNumber(252,289,0x80,0,90-find+1);
|
||
DrawFlatButton(155,300,115,14,582,0xAFFFAF,"‡ ®¢® (F2)");
|
||
WriteText(4,304,0x80,0x000000,"Made by Artemonische,2010");
|
||
}
|
||
IF (find==91)
|
||
{
|
||
WriteText(70,100,0x80,0x000000,"‚ë 諨 ¢á¥ ç¨á« ! :)");
|
||
DrawFlatButton(100,110,70,20,582,0xE4DFE1,"‡ ®¢® (F2)");
|
||
}
|
||
WindowRedrawStatus(2); //ª®¥æ ¯¥à¥à¨á®¢ª¨ ®ª
|
||
}
|
||
|
||
void draw_buttons()
|
||
{
|
||
int i,tempi,tempj;
|
||
FOR (i=1;i<=81;i++)
|
||
{
|
||
IF (box[i].mark==1)
|
||
{
|
||
tempi=box[i].y*30-30;
|
||
tempj=30*box[i].x-16;
|
||
DefineButton(tempi,tempj,29,29,box[i].button_id,0xAFFFAF);
|
||
WriteNumber(tempi+11,tempj+11,0x80,0,box[i].text);
|
||
}
|
||
}
|
||
}
|
||
|
||
void initialization()
|
||
{
|
||
int i,j,t;
|
||
t=0;
|
||
FOR (i=1;i<=9;i++)
|
||
{
|
||
FOR (j=1;j<=9;j++)
|
||
{
|
||
t++;
|
||
box[t].x=j;
|
||
box[t].y=i;
|
||
box[t].mark=1;
|
||
box[t].button_id=500+t;
|
||
box[t].text=Generate(t);
|
||
}
|
||
}
|
||
}
|
||
|
||
int Generate(int xx)
|
||
{
|
||
int temp,k,p;
|
||
p=2;
|
||
WHILE (p==2)
|
||
{
|
||
temp=random(81)+10;
|
||
p=1;
|
||
FOR (k=1; k<xx; k++)
|
||
{
|
||
IF (box[k].text==temp)
|
||
{
|
||
p=2;
|
||
BREAK;
|
||
}
|
||
}
|
||
}
|
||
return temp;
|
||
}
|
||
stop:
|