|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | |
Dialogs, StdCtrls, ExtCtrls; | |
TForm1 = class(TForm) | |
Panel1: TPanel; | |
Panel2: TPanel; | |
Panel3: TPanel; | |
Button1: TButton; | |
Button2: TButton; | |
Button3: TButton; | |
Shape1: TShape; | |
Timer1: TTimer; | |
procedure FormCreate(Sender: TObject); | |
procedure Button2Click(Sender: TObject); | |
procedure FormClose(Sender: TObject; var Action: TCloseAction); | |
procedure Shape1MouseDown(Sender: TObject; Button: TMouseButton; | |
Shift: TShiftState; X, Y: Integer); | |
procedure Button1Click(Sender: TObject); | |
procedure Timer1Timer(Sender: TObject); | |
procedure Button3Click(Sender: TObject); | |
{ Private declarations } | |
{ Public declarations } | |
Form1: TForm1; | |
Dot:Array[1..1000] of TShape; | |
n,s,f:integer; | |
cf,ct:TColor; | |
procedure TForm1.FormCreate(Sender: TObject); | |
procedure TForm1.Button2Click(Sender: TObject); | |
Dot[f]:=TShape.Create(form1); | |
Dot[f].Top:=random(panel2.Height-s); | |
Dot[f].Left:=random(panel2.Width-s); | |
if color=0 then Dot[f].Brush.Color:=cf | |
else Dot[f].Brush.Color:=ct; | |
Dot[f].OnMouseDown:=Shape1MouseDown; | |
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); | |
for f:=1 to n do Dot[f].Free; | |
procedure TForm1.Shape1MouseDown(Sender: TObject; Button: TMouseButton; | |
Shift: TShiftState; X, Y: Integer); | |
Tshape(sender).Visible:=false; | |
if TShape(sender).Brush.Color=cf then | |
panel3.Font.Color:=clred; | |
panel3.Caption:='НЕУДАЧНИК!!!'; | |
if (Dot[f].Visible=true) and (Dot[f].Brush.Color=ct) then p:=true; | |
panel3.Font.Color:=clred; | |
panel3.Caption:='Красавчег'; | |
procedure TForm1.Button1Click(Sender: TObject); | |
procedure TForm1.Timer1Timer(Sender: TObject); | |
Dot[f].Left:=Dot[f].Left+random(5)-2; | |
Dot[f].Top:=Dot[f].Top+random(5)-2; | |
if Dot[f].Left<1 then Dot[f].Left:=1; | |
if Dot[f].Top<1 then Dot[f].Top:=1; | |
if Dot[f].Top>panel2.Height - s then Dot[f].Top:=panel2.Height-s; | |
if Dot[f].Left>panel2.Width - s then Dot[f].Left:=panel2.Width-s; | |
procedure TForm1.Button3Click(Sender: TObject); | |