Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- int start_x1 = 200;
- int start_y1 = 0;
- int start_x2 = 240;
- int start_y2 = 40;
- TColor color[6] = {clPurple, clGreen, clYellow, clAqua, clRed, clBlue};
- int stop = 625;
- int num = rand() % 6;
- int score = 0;
- //int arr_figure[2][4] = {{200, 0, 240, 40}, {200, 0, 240, 80}};
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Timer1Timer(TObject *Sender)
- {
- Form1->Canvas->Brush->Color = color[num];
- Form1->Canvas->Pen->Color = color[num];
- Form1->Canvas->Rectangle(start_x1, start_y1, start_x2, start_y2);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Timer2Timer(TObject *Sender)
- {
- if(start_y2 < stop)
- {
- bool yes = False;
- for(int i = 0; i < 6; i++)
- {
- if(Form1->Canvas->Pixels[start_x1 + 20][start_y1 + 50] == color[i])
- {
- yes = True;
- }
- }
- if (yes)
- {
- start_x1 = 200;
- start_y1 = 0;
- start_x2 = start_x1 + 40;
- start_y2 = 40;
- num = rand() % 6;
- }
- else
- {
- Form1->Canvas->Brush->Color = clBtnFace;
- Form1->Canvas->Pen->Color = clBtnFace;
- Form1->Canvas->Rectangle(start_x1, start_y1, start_x2, start_y2);
- start_y1 += 40;
- start_y2 += 40;
- }
- }
- else
- {
- start_x1 = 200;
- start_y1 = 0;
- start_x2 = start_x1 + 40;
- start_y2 = 40;
- num = rand() % 6;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- if(start_x1 - 10 > 40)
- {
- Form1->Canvas->Brush->Color = clBtnFace;
- Form1->Canvas->Pen->Color = clBtnFace;
- Form1->Canvas->Rectangle(start_x1, start_y1, start_x2, start_y2);
- start_x1 -= 40;
- start_x2 -= 40;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- if(start_x2 + 40 < 405)
- {
- Form1->Canvas->Brush->Color = clBtnFace;
- Form1->Canvas->Pen->Color = clBtnFace;
- Form1->Canvas->Rectangle(start_x1, start_y1, start_x2, start_y2);
- start_x1 += 40;
- start_x2 += 40;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button3Click(TObject *Sender)
- {
- Form1->Canvas->Pen->Width = 5;
- Form1->Canvas->Pen->Color = clBlack;
- Form1->Canvas->Brush->Color = clBtnFace;
- Form1->Canvas->Rectangle(37, 0, 403, 643);
- Form1->Canvas->Pen->Width = 1;
- Timer1->Enabled = True;
- Timer2->Enabled = True;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Timer3Timer(TObject *Sender)
- {
- int start_y = 610;
- int start_x = 57;
- bool block[9] = {False, False, False, False, False, False, False, False, False};
- for(int i = 0; i < 1; i++)
- {
- for(int j = 0; j < 9; j++)
- {
- for(int k = 0; k < 6; k++)
- {
- if(Form1->Canvas->Pixels[start_x][start_y] == color[k])
- {
- block[j] = True;
- //Form1->Canvas->TextOut(start_x, start_y - 30, "Da");
- }
- }
- start_x += 40;
- }
- bool line_is_clean = True;
- for(int i = 0; i < 9; i++)
- {
- if(block[i] == False)
- {
- line_is_clean = False;
- break;
- }
- }
- if(line_is_clean)
- {
- score += 100;
- int start_x1 = 40;
- int start_y1 = 600;
- int start_x2 = start_x1 + 40;
- int start_y2 = start_y1 + 40;
- for(int j = 0; j < 9; j++)
- {
- Form1->Canvas->Brush->Color = clBtnFace;
- Form1->Canvas->Pen->Color = clBtnFace;
- Form1->Canvas->Rectangle(start_x1, start_y1, start_x2, start_y2);
- start_x1 += 40;
- start_x2 += 40;
- }
- Label1->Caption = "Очков: " + IntToStr(score);
- }
- start_x = 57;
- start_y -= 40;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button4Click(TObject *Sender)
- {
- Timer1->Enabled = False;
- Timer2->Enabled = False;
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement