Subversion Repositories Kolibri OS

Rev

Rev 1805 | Rev 1827 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1805 yogev_ezra 1
//(C) Artemonische, 2010
2
 
3
#pragma option meos
4
//#include "..\lib\kolibri.h--" //подключаем библиотеку с KolibriOS API
5
#include "kolibri.h--"
6
 
7
int find=10;
8
struct
9
	{
10
	int x;
11
	int y;
12
	int button_id;
13
	int mark;
14
	int text;
15
	}box[81];
16
 
17
void main()
18
{
19
	int button,tempi,tempj;
20
	randomize();
21
	initialization();
22
	draw_window();
23
	draw_buttons();
24
	loop()
25
	{
26
		switch(WaitEvent())
27
		{
1826 yogev_ezra 28
			case evButton:
1805 yogev_ezra 29
				button=GetButtonID();
1826 yogev_ezra 30
				if (button==1)
1805 yogev_ezra 31
					{
32
					ExitProcess();
33
					}
1826 yogev_ezra 34
				if (button==582)
1805 yogev_ezra 35
					{
36
					find=10;
37
					initialization();
38
					draw_window();
39
					draw_buttons();
40
					}
41
				if (button>500) && (button<582) && (box[button-500].text == find)
42
					{
43
					box[button-500].mark=2;
44
					find++;
45
					if (find==91)
46
						{
47
						draw_window();
48
						}
49
					else
50
						{
51
						DeleteButton(button);
52
						tempi=box[button-500].y*30-30;
53
						tempj=30*box[button-500].x-16;
54
						DrawBar(tempi,tempj,30,30,0xDCFFDC);
55
						DrawBar(70,289,16,8,0xDCFFDC);
56
						DrawBar(252,289,16,8,0xDCFFDC);
57
						WriteNumber(70,289,0x80,0,find);
58
						WriteNumber(252,289,0x80,0,90-find+1);
59
						}
60
					}
1826 yogev_ezra 61
				break;
62
			case evKey: //если произошло нажатие клавиши на клавиатуре
63
				if (GetKey()==051)
1805 yogev_ezra 64
					{
65
					find=10;
66
					initialization();
67
					draw_window();
68
					draw_buttons();
69
					}
1826 yogev_ezra 70
				break;
71
			case evReDraw:
1805 yogev_ezra 72
				draw_window();
73
				draw_buttons();
1826 yogev_ezra 74
				break;
1805 yogev_ezra 75
		}
76
	}
77
	ExitProcess();
78
}
79
 
80
void draw_window()
81
{
82
	WindowRedrawStatus(1); //начало перерисовки окна
83
	DefineAndDrawWindow(300,176,280,340,0x34,0xDCFFDC,0,0,"FindNumbers v1.1"); //рисуем окно
84
	DrawBar(0,13,271,1,0x0CFF0C); //линия сверху
85
	DrawBar(0,285,271,1,0x0CFF0C);
86
	DrawBar(0,299,271,1,0x0CFF0C); //линия снизу
87
	if (find<=90)
88
		{
89
		WriteText(4,4,0x80,0x000000,"Соберите все числа от 10 до 90 по порядку...");
90
		WriteText(4,289,0x80,0x000000,"Ищем число: ");
91
		WriteText(162,289,0x80,0x000000,"Осталось найти: ");
92
		WriteNumber(70,289,0x80,0,find);
93
		WriteNumber(252,289,0x80,0,90-find+1);
94
		DrawFlatButton(155,300,115,14,582,0xAFFFAF,"Заново (F2)");
95
		WriteText(4,304,0x80,0x000000,"Made by Artemonische,2010");
96
		}
1826 yogev_ezra 97
	if (find==91)
1805 yogev_ezra 98
		{
99
		WriteText(70,100,0x80,0x000000,"Вы нашли все числа! :)");
100
		DrawFlatButton(100,110,70,20,582,0xE4DFE1,"Заново (F2)");
101
		}
102
	WindowRedrawStatus(2); //конец перерисовки окна
103
}
104
 
105
void draw_buttons()
106
{
107
int i,tempi,tempj;
108
	for (i=1;i<=81;i++)
109
		{
1826 yogev_ezra 110
		if (box[i].mark==1)
1805 yogev_ezra 111
			{
112
			tempi=box[i].y*30-30;
113
			tempj=30*box[i].x-16;
114
			DefineButton(tempi,tempj,29,29,box[i].button_id,0xAFFFAF);
115
			WriteNumber(tempi+11,tempj+11,0x80,0,box[i].text);
116
			}
117
		}
118
}
119
 
120
void initialization()
121
{
122
int i,j,t;
123
t=0;
1826 yogev_ezra 124
	for (i=1;i<=9;i++)
1805 yogev_ezra 125
		{
1826 yogev_ezra 126
		for (j=1;j<=9;j++)
1805 yogev_ezra 127
			{
128
			t++;
129
			box[t].x=j;
130
			box[t].y=i;
131
			box[t].mark=1;
132
			box[t].button_id=500+t;
133
			box[t].text=Generate(t);
134
			}
135
		}
136
}
137
 
138
int Generate(int xx)
139
{
140
	int temp,k,p;
141
	p=2;
1826 yogev_ezra 142
	while (p==2)
1805 yogev_ezra 143
		{
144
		temp=random(81)+10;
145
		p=1;
1826 yogev_ezra 146
		for (k=1; k
1805 yogev_ezra 147
			{
1826 yogev_ezra 148
			if (box[k].text==temp)
1805 yogev_ezra 149
				{
150
				p=2;
1826 yogev_ezra 151
				break;
1805 yogev_ezra 152
				}
153
			}
154
		}
155
	return temp;
156
}
157
stop: