Subversion Repositories Kolibri OS

Rev

Rev 6363 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. //(C) Artemonische, 2010
  2.  
  3. #pragma option meos
  4. //#include "..\lib\kolibri.h--" //¯®¤ª«îç ¥¬ ¡¨¡«¨®â¥ªã á KolibriOS API
  5. #include "kolibri.h--"
  6.  
  7. #ifndef AUTOBUILD
  8. #include "lang.h--"
  9. #endif
  10.  
  11. #ifdef LANG_RUS        
  12.         ?define TOP_TEXT_COL 4
  13.         ?define TOP_TEXT "‘®¡¥à¨â¥ ¢á¥ ç¨á«  ®â 10 ¤® 90 ¯® ¯®à浪ã..."
  14.         ?define BOT_LEFT_TEXT_COL 4
  15.         ?define BOT_LEFT_TEXT "ˆé¥¬ ç¨á«®: "
  16.         ?define BOT_RIGHT_TEXT_COL 162
  17.         ?define BOT_RIGHT_TEXT "Žáâ «®áì ­ ©â¨: "
  18.         ?define BOT_LEFT_NUMBER_COL 70
  19.         ?define BOT_RIGHT_NUMBER_COL 252
  20.         ?define F2_TEXT "‡ ­®¢® (F2)"
  21.         ?define WIN_TEXT "‚ë ­ è«¨ ¢á¥ ç¨á« ! :)"              
  22. #else
  23.         ?define TOP_TEXT_COL 2
  24.         ?define TOP_TEXT "Collect all numbers from 10 to 90 in order..."
  25.         ?define BOT_LEFT_TEXT_COL 2
  26.         ?define BOT_LEFT_TEXT "Looking for number: "
  27.         ?define BOT_RIGHT_TEXT_COL 156
  28.         ?define BOT_RIGHT_TEXT "Remains to find: "
  29.         ?define BOT_LEFT_NUMBER_COL 116
  30.         ?define BOT_RIGHT_NUMBER_COL 252
  31.         ?define F2_TEXT "Anew (F2)"
  32.         ?define WIN_TEXT "You have found all numbers! :)"
  33. #endif
  34.  
  35. int find=10;
  36. struct
  37.         {
  38.         int x;
  39.         int y;
  40.         int button_id;
  41.         int mark;
  42.         int text;
  43.         }box[81];
  44.  
  45. void main()
  46. {      
  47.         int button,tempi,tempj;
  48.         randomize();
  49.         initialization();
  50.         draw_window();
  51.         draw_buttons();
  52.         loop()
  53.         {
  54.                 switch(WaitEvent())
  55.                 {
  56.                         case evButton:
  57.                                 button=GetButtonID();
  58.                                 IF (button==1)
  59.                                         {
  60.                                         ExitProcess();
  61.                                         }
  62.                                 IF (button==582)
  63.                                         {
  64.                                         find=10;
  65.                                         initialization();
  66.                                         draw_window();
  67.                                         draw_buttons();
  68.                                         }
  69.                                 if (button>500) && (button<582) && (box[button-500].text == find)
  70.                                         {
  71.                                         box[button-500].mark=2;
  72.                                         find++;
  73.                                         IF (find==91)
  74.                                                 {
  75.                                                 draw_window();
  76.                                                 }
  77.                                         else
  78.                                                 {
  79.                                                 DeleteButton(button);
  80.                                                 tempi=box[button-500].y*30-30;
  81.                                                 tempj=30*box[button-500].x-16;
  82.                                                 DrawBar(tempi,tempj,30,30,0xDCFFDC);
  83.                                                 DrawBar(70,289,16,8,0xDCFFDC);
  84.                                                 DrawBar(252,289,16,8,0xDCFFDC);
  85.                                                 WriteNumber(70,289,0x80,0,find);
  86.                                                 WriteNumber(252,289,0x80,0,90-find+1);
  87.                                                 }
  88.                                         }
  89.                                 BREAK;
  90.                         case evKey: //¥á«¨ ¯à®¨§®è«® ­ ¦ â¨¥ ª« ¢¨è¨ ­  ª« ¢¨ âãà¥
  91.                                 IF (GetKey()==051)
  92.                                         {
  93.                                         find=10;
  94.                                         initialization();
  95.                                         draw_window();
  96.                                         draw_buttons();
  97.                                         }
  98.                                 BREAK;
  99.                         case evReDraw:
  100.                                 draw_window();
  101.                                 draw_buttons();
  102.                                 break;
  103.                 }
  104.         }
  105.         ExitProcess();
  106. }
  107.  
  108. void draw_window()
  109. {
  110.         WindowRedrawStatus(1); //­ ç «® ¯¥à¥à¨á®¢ª¨ ®ª­ 
  111.         DefineAndDrawWindow(300,176,280,340,0x34,0xDCFFDC,0,0,"FindNumbers v1.1"); //à¨á㥬 ®ª­®
  112.         DrawBar(0,13,271,1,0x0CFF0C); //«¨­¨ï ᢥàåã
  113.         DrawBar(0,285,271,1,0x0CFF0C);
  114.         DrawBar(0,299,271,1,0x0CFF0C); //«¨­¨ï á­¨§ã
  115.         if (find<=90)
  116.                 {
  117.                 WriteText(TOP_TEXT_COL,4,0x80,0x000000,TOP_TEXT);
  118.                 WriteText(BOT_LEFT_TEXT_COL,289,0x80,0x000000,BOT_LEFT_TEXT);
  119.                 WriteText(BOT_RIGHT_TEXT_COL,289,0x80,0x000000,BOT_RIGHT_TEXT);
  120.                 WriteNumber(BOT_LEFT_NUMBER_COL,289,0x80,0,find);
  121.                 WriteNumber(BOT_RIGHT_NUMBER_COL,289,0x80,0,90-find+1);
  122.                 DrawFlatButton(155,300,115,14,582,0xAFFFAF,F2_TEXT);
  123.                 WriteText(2,304,0x80,0x000000,"Made by Artemonische,2010");
  124.                 }
  125.         IF (find==91)
  126.                 {
  127.                 WriteText(70,100,0x80,0x000000,WIN_TEXT);
  128.                 DrawFlatButton(100,110,70,20,582,0xE4DFE1,F2_TEXT);
  129.                 }
  130.         WindowRedrawStatus(2); //ª®­¥æ ¯¥à¥à¨á®¢ª¨ ®ª­ 
  131. }
  132.  
  133. void draw_buttons()
  134. {
  135. int i,tempi,tempj;
  136.         FOR (i=1;i<=81;i++)
  137.                 {
  138.                 IF (box[i].mark==1)
  139.                         {
  140.                         tempi=box[i].y*30-30;
  141.                         tempj=30*box[i].x-16;
  142.                         DefineButton(tempi,tempj,29,29,box[i].button_id,0xAFFFAF);
  143.                         WriteNumber(tempi+11,tempj+11,0x80,0,box[i].text);
  144.                         }
  145.                 }
  146. }
  147.  
  148. void initialization()
  149. {
  150. int i,j,t;
  151. t=0;
  152.         FOR (i=1;i<=9;i++)
  153.                 {
  154.                 FOR (j=1;j<=9;j++)
  155.                         {
  156.                         t++;
  157.                         box[t].x=j;
  158.                         box[t].y=i;
  159.                         box[t].mark=1;
  160.                         box[t].button_id=500+t;
  161.                         box[t].text=Generate(t);
  162.                         }
  163.                 }
  164. }
  165.  
  166. int Generate(int xx)
  167. {
  168.         int temp,k,p;
  169.         p=2;
  170.         WHILE (p==2)
  171.                 {
  172.                 temp=random(81)+10;
  173.                 p=1;
  174.                 FOR (k=1; k<xx; k++)
  175.                         {
  176.                         IF (box[k].text==temp)
  177.                                 {
  178.                                 p=2;
  179.                                 BREAK;
  180.                                 }
  181.                         }
  182.                 }
  183.         return temp;
  184. }
  185. stop:
  186.