Advertisement
SomeBody_Aplle

Untitled

Jan 29th, 2022
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.39 KB | None | 0 0
  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #pragma hdrstop
  5.  
  6. #include "Unit1.h"
  7. //---------------------------------------------------------------------------
  8. #pragma package(smart_init)
  9. #pragma resource "*.dfm"
  10. TForm1 *Form1;
  11.  
  12. int start_x1 = 200;
  13. int start_y1 = 0;
  14. int start_x2 = 240;
  15. int start_y2 = 40;
  16.  
  17. TColor color[6] = {clPurple, clGreen, clYellow, clAqua, clRed, clBlue};
  18. int stop = 625;
  19. int num = rand() % 6;
  20. int score = 0;
  21.  
  22. //int arr_figure[2][4] = {{200, 0, 240, 40}, {200, 0, 240, 80}};
  23.  
  24. //---------------------------------------------------------------------------
  25. __fastcall TForm1::TForm1(TComponent* Owner)
  26.     : TForm(Owner)
  27. {
  28.  
  29. }
  30. //---------------------------------------------------------------------------
  31. void __fastcall TForm1::Timer1Timer(TObject *Sender)
  32. {
  33.  
  34.     Form1->Canvas->Brush->Color = color[num];
  35.     Form1->Canvas->Pen->Color = color[num];
  36.     Form1->Canvas->Rectangle(start_x1, start_y1, start_x2, start_y2);
  37. }
  38. //---------------------------------------------------------------------------
  39. void __fastcall TForm1::Timer2Timer(TObject *Sender)
  40. {
  41.     if(start_y2 < stop)
  42.     {
  43.         bool yes = False;
  44.         for(int i = 0; i < 6; i++)
  45.         {
  46.             if(Form1->Canvas->Pixels[start_x1 + 20][start_y1 + 50] == color[i])
  47.             {
  48.                 yes = True;
  49.             }
  50.         }
  51.         if (yes)
  52.         {
  53.             start_x1 = 200;
  54.             start_y1 = 0;
  55.             start_x2 = start_x1 + 40;
  56.             start_y2 = 40;
  57.             num = rand() % 6;
  58.         }
  59.         else
  60.         {
  61.             Form1->Canvas->Brush->Color = clBtnFace;
  62.             Form1->Canvas->Pen->Color = clBtnFace;
  63.             Form1->Canvas->Rectangle(start_x1, start_y1, start_x2, start_y2);
  64.             start_y1 += 40;
  65.             start_y2 += 40;
  66.         }
  67.     }
  68.     else
  69.     {
  70.             start_x1 = 200;
  71.             start_y1 = 0;
  72.             start_x2 = start_x1 + 40;
  73.             start_y2 = 40;
  74.             num = rand() % 6;
  75.     }
  76. }
  77. //---------------------------------------------------------------------------
  78. void __fastcall TForm1::Button1Click(TObject *Sender)
  79. {
  80.     if(start_x1 - 10 > 40)
  81.     {
  82.         Form1->Canvas->Brush->Color = clBtnFace;
  83.         Form1->Canvas->Pen->Color = clBtnFace;
  84.         Form1->Canvas->Rectangle(start_x1, start_y1, start_x2, start_y2);
  85.         start_x1 -= 40;
  86.         start_x2 -= 40;
  87.     }
  88. }
  89. //---------------------------------------------------------------------------
  90. void __fastcall TForm1::Button2Click(TObject *Sender)
  91. {
  92.     if(start_x2 + 40 < 405)
  93.     {
  94.         Form1->Canvas->Brush->Color = clBtnFace;
  95.         Form1->Canvas->Pen->Color = clBtnFace;
  96.         Form1->Canvas->Rectangle(start_x1, start_y1, start_x2, start_y2);
  97.         start_x1 += 40;
  98.         start_x2 += 40;
  99.     }
  100. }
  101. //---------------------------------------------------------------------------
  102. void __fastcall TForm1::Button3Click(TObject *Sender)
  103. {
  104.     Form1->Canvas->Pen->Width = 5;
  105.     Form1->Canvas->Pen->Color = clBlack;
  106.     Form1->Canvas->Brush->Color = clBtnFace;
  107.     Form1->Canvas->Rectangle(37, 0, 403, 643);
  108.     Form1->Canvas->Pen->Width = 1;
  109.     Timer1->Enabled = True;
  110.     Timer2->Enabled = True;
  111. }
  112. //---------------------------------------------------------------------------
  113. void __fastcall TForm1::Timer3Timer(TObject *Sender)
  114. {
  115.  
  116.     int start_y = 610;
  117.     int start_x = 57;
  118.  
  119.     bool block[9] = {False, False, False, False, False, False, False, False, False};
  120.  
  121.     for(int i = 0; i < 1; i++)
  122.     {
  123.         for(int j = 0; j < 9; j++)
  124.         {
  125.  
  126.             for(int k = 0; k < 6; k++)
  127.             {
  128.                 if(Form1->Canvas->Pixels[start_x][start_y] == color[k])
  129.                 {
  130.                     block[j] = True;
  131.                     //Form1->Canvas->TextOut(start_x, start_y - 30, "Da");
  132.                 }
  133.                
  134.             }
  135.             start_x += 40;
  136.         }
  137.  
  138.         bool line_is_clean = True;
  139.         for(int i = 0; i < 9; i++)
  140.         {
  141.             if(block[i] == False)
  142.             {
  143.                line_is_clean = False;
  144.                break;
  145.             }
  146.         }
  147.  
  148.         if(line_is_clean)
  149.         {
  150.             score += 100;
  151.             int start_x1 = 40;
  152.             int start_y1 = 600;
  153.             int start_x2 = start_x1 + 40;
  154.             int start_y2 = start_y1 + 40;
  155.             for(int j = 0; j < 9; j++)
  156.             {
  157.                 Form1->Canvas->Brush->Color = clBtnFace;
  158.                 Form1->Canvas->Pen->Color = clBtnFace;
  159.                 Form1->Canvas->Rectangle(start_x1, start_y1, start_x2, start_y2);
  160.                 start_x1 += 40;
  161.                 start_x2 += 40;
  162.  
  163.             }
  164.             Label1->Caption = "Очков: " + IntToStr(score);
  165.         }
  166.         start_x = 57;
  167.         start_y -= 40;
  168.     }
  169. }
  170. //---------------------------------------------------------------------------
  171.  
  172. void __fastcall TForm1::Button4Click(TObject *Sender)
  173. {
  174.     Timer1->Enabled = False;
  175.     Timer2->Enabled = False;
  176. }
  177. //---------------------------------------------------------------------------
  178.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement