Subversion Repositories Kolibri OS

Rev

Rev 6368 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6368 Rev 8287
Line 1... Line 1...
1
//(C) Artemonische, 2010
1
//(C) Artemonische, 2010
Line 2... Line 2...
2
 
2
 
3
#pragma option meos
3
#pragma option meos
4
//#include "..\lib\kolibri.h--" //¯®¤ª«îç ¥¬ ¡¨¡«¨®â¥ªã á KolibriOS API
-
 
Line 5... Line 4...
5
#include "kolibri.h--"
4
#include "kolibri.h--" //¯®¤ª«îç ¥¬ ¡¨¡«¨®â¥ªã á KolibriOS API
6
 
5
 
7
#ifndef AUTOBUILD
6
#ifndef AUTOBUILD
Line 30... Line 29...
30
	?define BOT_RIGHT_NUMBER_COL 252
29
	?define BOT_RIGHT_NUMBER_COL 252
31
	?define F2_TEXT "Anew (F2)"
30
	?define F2_TEXT " Anew (F2) "
32
	?define WIN_TEXT "You have found all numbers! :)"
31
	?define WIN_TEXT "You have found all numbers! :)"
33
#endif
32
#endif
Line 34... Line 33...
34
 
33
 
35
int find=10;
34
int find;
36
struct
-
 
37
	{
35
struct {
38
	int x;
36
	int x;
39
	int y;
37
	int y;
40
	int button_id;
38
	int button_id;
41
	int mark;
39
	int mark;
42
	int text;
40
	int text;
Line -... Line 41...
-
 
41
}box[81];
-
 
42
 
43
	}box[81];
43
#define BUTTON_NEW_GAME 582
44
 
44
 
45
void main()
45
void main()
46
{	
46
{	
47
	int button,tempi,tempj;
-
 
48
	randomize();
47
	int button,tempi,tempj;
49
	initialization();
-
 
50
	draw_window();
-
 
51
	draw_buttons();
-
 
52
	loop()
48
	randomize();
53
	{
49
	new_game();
54
		switch(WaitEvent())
50
	loop() switch(@WaitEvent())
55
		{
51
	{
56
			case evButton:
52
		case evButton:
57
				button=GetButtonID();
53
			button=@GetButtonID();
58
				IF (button==1)
54
			IF (button==1)
59
					{
55
				{
60
					ExitProcess();
56
				ExitProcess();
61
					}
57
				}
62
				IF (button==582)
-
 
63
					{
-
 
64
					find=10;
58
			IF (button==BUTTON_NEW_GAME)
65
					initialization();
-
 
66
					draw_window();
59
				{
67
					draw_buttons();
60
				new_game();
68
					}
61
				}
69
				if (button>500) && (button<582) && (box[button-500].text == find)
62
			if (button>500) && (button
70
					{
63
				{
71
					box[button-500].mark=2;
64
				box[button-500].mark=2;
72
					find++;
65
				find++;
Line 86... Line 79...
86
						WriteNumber(252,289,0x80,0,90-find+1);
79
					WriteNumber(252,289,0x80,0,90-find+1);
87
						}
80
					}
88
					}
81
				}
89
				BREAK;
82
			BREAK;
90
			case evKey: //¥á«¨ ¯à®¨§®è«® ­ ¦ â¨¥ ª« ¢¨è¨ ­  ª« ¢¨ âãà¥
83
		case evKey: //¥á«¨ ¯à®¨§®è«® ­ ¦ â¨¥ ª« ¢¨è¨ ­  ª« ¢¨ âãà¥
91
				IF (GetKey()==051)
84
			IF (@GetKey()==051) new_game(); //F2
92
					{
-
 
93
					find=10;
-
 
94
					initialization();
-
 
95
					draw_window();
-
 
96
					draw_buttons();
-
 
97
					}
-
 
98
				BREAK;
85
			BREAK;
99
			case evReDraw:
86
		case evReDraw:
100
				draw_window();
87
			draw_window();
101
				draw_buttons();
88
			draw_buttons();
102
				break;
-
 
103
		}
89
	}
104
	}
90
}
105
	ExitProcess();
-
 
106
}
-
 
Line 107... Line 91...
107
 
91
 
108
void draw_window()
92
void draw_window()
109
{
-
 
110
	WindowRedrawStatus(1); //­ ç «® ¯¥à¥à¨á®¢ª¨ ®ª­ 
93
{
111
	DefineAndDrawWindow(300,176,280,340,0x34,0xDCFFDC,0,0,"FindNumbers v1.1"); //à¨á㥬 ®ª­®
94
	DefineAndDrawWindow(300,176,280,343,0x34,0xDCFFDC,"FindNumbers");
112
	DrawBar(0,13,271,1,0x0CFF0C); //«¨­¨ï ᢥàåã
95
	DrawBar(0,13,271,1,0x0CFF0C); //«¨­¨ï ᢥàåã
113
	DrawBar(0,285,271,1,0x0CFF0C);
96
	DrawBar(0,285,271,1,0x0CFF0C);
114
	DrawBar(0,299,271,1,0x0CFF0C); //«¨­¨ï á­¨§ã
97
	DrawBar(0,299,271,1,0x0CFF0C); //«¨­¨ï á­¨§ã
115
	if (find<=90)
98
	if (find<=90)
116
		{
99
		{
117
		WriteText(TOP_TEXT_COL,4,0x80,0x000000,TOP_TEXT);
100
		WriteText(TOP_TEXT_COL,4,0x80,0x000000,TOP_TEXT);
118
		WriteText(BOT_LEFT_TEXT_COL,289,0x80,0x000000,BOT_LEFT_TEXT);
101
		WriteText(BOT_LEFT_TEXT_COL,289,0x80,0x000000,BOT_LEFT_TEXT);
119
		WriteText(BOT_RIGHT_TEXT_COL,289,0x80,0x000000,BOT_RIGHT_TEXT);
102
		WriteText(BOT_RIGHT_TEXT_COL,289,0x80,0x000000,BOT_RIGHT_TEXT);
120
		WriteNumber(BOT_LEFT_NUMBER_COL,289,0x80,0,find);
103
		WriteNumber(BOT_LEFT_NUMBER_COL,289,0x80,0,find);
121
		WriteNumber(BOT_RIGHT_NUMBER_COL,289,0x80,0,90-find+1);
104
		WriteNumber(BOT_RIGHT_NUMBER_COL,289,0x80,0,90-find+1);
122
		DrawFlatButton(155,300,115,14,582,0xAFFFAF,F2_TEXT);
105
		DrawNewGameButton(155,300,115,14,0xAFFFAF);
123
		WriteText(2,304,0x80,0x000000,"Made by Artemonische,2010");
106
		WriteText(2,304,0x80,0x000000,"Made by Artemonische,2010");
124
		}
107
		}
125
	IF (find==91)
108
	IF (find==91)
126
		{
109
		{
127
		WriteText(70,100,0x80,0x000000,WIN_TEXT);
110
		WriteText(70,100,0x80,0x000000,WIN_TEXT);
-
 
111
		DrawNewGameButton(100,110,70,20,0xE4DFE1);
-
 
112
		}
-
 
113
}
-
 
114
 
-
 
115
void DrawNewGameButton(dword x,y,width,height,color)
-
 
116
{
-
 
117
	DefineButton(x,y,width,height,BUTTON_NEW_GAME,color);
128
		DrawFlatButton(100,110,70,20,582,0xE4DFE1,F2_TEXT);
118
	WriteText(-11*6+width/2+x+1,height/2-3+y,0x80,0,F2_TEXT,0);
-
 
119
}
-
 
120
 
-
 
121
void new_game()
-
 
122
{
129
		}
123
	find=10;
-
 
124
	initialization();
-
 
125
	draw_window();
130
	WindowRedrawStatus(2); //ª®­¥æ ¯¥à¥à¨á®¢ª¨ ®ª­ 
126
	draw_buttons();
Line 131... Line 127...
131
}
127
}
132
 
128
 
133
void draw_buttons()
129
void draw_buttons()