//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; TPoint p[149],vodor[233]; int fx1,fx2,fy1,fy2;//координаты рыбок int x1 = 76; int x2 = 300; int st1 = 1; int st2 = 2; int df1,df2;//направление движения int vod[] = { 497,443,498,396,498,371,502,350,511,333,527,321,540,312,563,300,578,290,589,276,597,266,605,255,607,245,614,219,618,198,624,179,632,169,634,164,636,158,618,201,616,199,616,189,611,161,605,148,599,139,594,134,590, 129,590,129,612,159,617,206,605,252,588,210,533,165,557,185,557,158,560,145,570,136,573,133,559,148,567,150,576,149,580,147,563,147,558,151,557,153,556,160,556,168,549,151,541,145,538,142,550,153,557,167,556,186, 550,179,531,183,522,188,509,202,525,187,493,185,496,185,512,184,512,187,524,186,533,184,551,181,538,168,509,171, 537,169,526,150,536,172,586,209,599,236,605,255,613,228,654,206,632,218,644,188,681,162,660,175,657,113,658,145,627,121,644,137,647,122,645,133,659,145,674,116,675,92,675,113,658,147,661,178,641,192,663,192,643, 193,635,213,671,224,638,216,613,228,652,240,612,229,589,282,651,266,576,289,546, 244,567,273,569,224,569,243,533,216,567,241,568,275,510,255,536,263,514,238,535,264,511,282,524,271,477,266,502,270,479,250,494,264,487,232,492,246,502,231,493,245,496,269,527,273,521,290,534,260,544,266,533,236, 542,263,529,258,519,226,528,259,566,274,578,288,615,275,629,246,616,275,556,305,625,316,665,291,621,314,554,305,588,311,617,335,649,328,615,334,590,311,574,310,590,346,602,334,590,343,608,366,615,347,609,366,598, 355,587,382,613,394,588,381,594,367,569,367,570,375,577,367,581,387,583,368,593,367,596,351,586,333,572,343,582,334,574,307,548,306,509,338,503,359,480,310,377,243,431,277,402,179,414,221,454,150,430,193,413,145, 361,116,414,146,381,145,399,144,383,166,396,143,412,142,430,192,417,219,366,195,399,212,382,186,388,176,383,187,398,211,414,217,411,168,415,221,425,256,393,234,426,262,429,275,360,282,427,276,381,280,362,253,382, 279,416,278,388,313,417,277,442,284,460,294,429,305,457,295,456,263,459,294,458,263,471,230,458,265,446,230,456,279,465,298,482,313,499,356,494,373,496,440,493,439,491,372,496,354,494,435 }; int t1[] = {2,44,15,54,21,64,21,69,15,74,5,81,32,76,35,69,34,55,28,44,23,41,0,45,12,51,29,47, 35,53,19,59,20,69,35,63,34,75,53,79,96,74,124,60,114,49,104,37,113,23,87,19,52, 29,23,40,43,32,36,20,83,0,90,0,92,16,93,19,85,19,83,20,78,3,69,5,75,22,65,25,61, 10,54,11,59,27,51,30,46,18,51,31,55,27,92,19,115,22,133,23,147,27,155,35,157,38, 136,42,158,43,158,46,154,50,125,60,110,66,112,77,107,82,105,89,100,93,100,72,104, 70,108,82,111,67,126,59,108,38,116,22,129,23,121,28,129,30,133,26,129,23,129,23,129,23}; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { fx1 = 190; fy1 = 210; x2 = ClientWidth-240; fy2 = ClientHeight-340; df1 = 3; df2 = 1; } //--------------------------------------------------------------------------- void vodorosli1() { Form1->Canvas->Pen->Width=1; Form1->Canvas->Pen->Color=(TColor)8954880; Form1->Canvas->MoveTo(vodor[0].x=vod[0],vodor[0].y=vod[1]); for(int j=0; j<15; j++) { for(int i=0; i<=466; i+=2) { vodor[i/2].x = 80*j-vod[i]/2; vodor[i/2].y = (j%2==20?260:260)+vod[i+1]/(j%2==0?2:1.6); } Form1->Canvas->Polyline(vodor,232); } } void vodorosli2() { Form1->Canvas->Pen->Width=3; Form1->Canvas->Pen->Color=(TColor)8954880; Form1->Canvas->MoveTo(vodor[0].x=vod[0],vodor[0].y=vod[1]); for(int i=0; i<=466; i+=2) { vodor[i/2].x = vod[i]; vodor[i/2].y = vod[i+1]; } Form1->Canvas->Polyline(vodor,232); } void change1() { switch(df1) { case 1: x1-=st1; fy1-=st1; break; case 2: fy1-=st1; break; case 3: x1+=st1; fy1-=st1; break; case 4: x1-=st1; break; case 6: x1+=st1; break; case 7: x1+=st1; fy1-=st1; break; case 8: fy1+=st1; break; case 9: x1+=st1; fy1+=st1; break; } if(x1<10) {x1=10; df1 = random(9);} else if (x1>(Form1->ClientWidth-160)) {x1 = Form1->ClientWidth-160; df1 = random(9);} if(fy1<0) {fy1=0; df1 = random(9);} else if (fy1>(Form1->ClientHeight-50)) {fy1 = Form1->ClientHeight-50; df1 = random(9);} } void change2() { switch(df2) { case 1: x2-=st2; fy2-=st2; break; case 2: fy2-=st2; break; case 3: x2+=st2; fy2-=st2; break; case 4: x2-=st2; break; case 6: x2+=st2; break; case 7: x2+=st2; fy2-=st2; break; case 8: fy2+=st2; break; case 9: x2+=st2; fy2+=st2; break; } if(x2<10) {x2=10; df2 = random(9);} else if (x2>(Form1->ClientWidth-50)) {x2 = Form1->ClientWidth-50; df2 = random(9);} if(fy2<0) {fy2=0; df2 = random(9);} else if (fy2>(Form1->ClientHeight-20)) {fy2 = Form1->ClientHeight-20; df2 = random(9);} } void fish1() { Form1->Canvas->Pen->Width=1; Form1->Canvas->Pen->Color=(TColor)0; int dir = 0; if(df1==3 || df1==6 || df1==9) dir = 158; Form1->Canvas->MoveTo(p[0].x=t1[0]+x1,p[0].y=t1[1]+fy1); for(int i=0; i<=150; i+=2) { p[i/2].x = (dir!=0?t1[i]:-t1[i]+158)+x1; p[i/2].y = t1[i+1]+fy1; } Form1->Canvas->Polyline(p,75); change1(); } void fish2() { Form1->Canvas->Pen->Width=1; Form1->Canvas->Pen->Color=(TColor)0; int dir = 0; if(df2==1 || df2==4 || df2==7) dir = 158; Form1->Canvas->MoveTo(p[0].x=t1[0]/3.2+x2,p[0].y=t1[1]/3.2+fy2); for(int i=0; i<=150; i+=2) { p[i/2].x = (dir==0?t1[i]:dir-t1[i])/3.2+x2; p[i/2].y = (t1[i+1])/4.2+fy2; } Form1->Canvas->Polyline(p,75); change2(); } void __fastcall TForm1::FormPaint(TObject *Sender) { TRect aRect = Rect(0,0,ClientWidth,ClientHeight); Canvas->Brush->Color=(TColor)13748736; Canvas->FillRect(aRect); vodorosli1(); fish1(); vodorosli2(); fish2(); //Canvas->Brush->Color=8343874; //блок изменения значений randomize(); Canvas->TextOutA(250,2,IntToStr(x1)); if(random(6)==2) { df1 = random(9); } if(random(6)==3) { df2 = random(9); } if(random(6)==4) { //st1 = 3-st1; } if(random(6)==5) { //st2 = 3-st2; } Sleep(100); FormPaint(this); } //---------------------------------------------------------------------------