Subversion Repositories Kolibri OS

Rev

Rev 6368 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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