uses vcl,PointRect;
type
TDirection = (None,Up,Down,Left,Right);
var
Direction : TDirection;
x,i,wins,faults:word;
go,timeron,faulting: boolean;
//$VCLDESIGN+
var
Form1: Form;
Shape1: Shape;
Shape2: Shape;
Shape3: Shape;
Shape4: Shape;
Shape5: Shape;
Panel1: Panel;
TextLabel1: TextLabel;
TextLabel2: TextLabel;
TextLabel3: TextLabel;
TextLabel4: TextLabel;
TextLabel5: TextLabel;
TextLabel6: TextLabel;
TrackBar1: TrackBar;
Button1: Button;
Timer1: Timer;
//$VCLDESIGN-
procedure KeyDown(Key:integer);
begin
TextLabel6.Caption:='Èãðà..';
case Key of
VK_Left: begin Direction := Left; TrackBar1.Position:=TrackBar1.Position+1; end;
VK_Up: begin Direction := Up; TrackBar1.Position:=TrackBar1.Position+1; end;
VK_Right: begin Direction := Right; TrackBar1.Position:=TrackBar1.Position-1; end;
VK_Down: begin Direction := Down; TrackBar1.Position:=TrackBar1.Position-1; end;
VK_Escape: Halt;
107: TrackBar1.Position:=TrackBar1.Position+1;
109: TrackBar1.Position:=TrackBar1.Position-1;
end;
end;
procedure BackToStart;
begin
TextLabel6.Caption:='Àâàðèÿ!!!';
Timer1.Stop;
Shape5.Top:=384;
Shape5.Left:=288;
end;
procedure Timer1OnTimer;
begin
if((Shape5.Top <= 10)and(go=true)) then begin go:=false; inc(wins); TextLabel4.Caption:=IntToStr(wins); TextLabel6.Caption:='Óñïåõ'; Direction:=none; Shape5.Top:=384; Shape5.Left:=288;end;
if((Shape5.Top > Form1.Height div 2 - 5) and (Shape5.Top < Form1.Height div 2 + 5)) then go:=true;
if (
(InterSectRect(RectF(Shape1.Left,Shape1.Top,Shape1.Left+Shape1.Width,Shape1.Top+Shape1.Height),
RectF(Shape5.Left,Shape5.Top,Shape5.Left+Shape5.Width,Shape5.Top+Shape5.Height)))
or (InterSectRect(RectF(Shape2.Left,Shape2.Top,Shape2.Left+Shape2.Width,Shape2.Top+Shape2.Height),
RectF(Shape5.Left,Shape5.Top,Shape5.Left+Shape5.Width,Shape5.Top+Shape5.Height)))
or (InterSectRect(RectF(Shape3.Left,Shape3.Top,Shape3.Left+Shape3.Width,Shape3.Top+Shape3.Height),
RectF(Shape5.Left,Shape5.Top,Shape5.Left+Shape5.Width,Shape5.Top+Shape5.Height)))
or (InterSectRect(RectF(Shape4.Left,Shape4.Top,Shape4.Left+Shape4.Width,Shape4.Top+Shape4.Height),
RectF(Shape5.Left,Shape5.Top,Shape5.Left+Shape5.Width,Shape5.Top+Shape5.Height)))
)
then
if (faulting = false)
then
begin
faulting := true;
inc(faults);
TextLabel5.Caption:=IntToStr(faults);
BackToStart;
end
else
else faulting:=false;
if (Shape1.Left > Form1.Width) then Shape1.Left:=0; Shape1.Left:=Shape1.Left+x;
if (Shape2.Left < 0) then Shape2.Left:=Form1.Width; Shape2.Left:=Shape2.Left-(x+2);
if (Shape3.Left > Form1.Width) then Shape3.Left:=0; Shape3.Left:=Shape3.Left+(x+2);
if (Shape4.Left < 0) then Shape4.Left:=Form1.Width; Shape4.Left:=Shape4.Left-(x+3);
case Direction of
Left: begin Shape5.left:=Shape5.left-(x+2); if (Shape5.Left < 0) then Shape5.Left:=Form1.Width; end;
Up: begin Shape5.Top:=Shape5.Top-(x+2); if (Shape5.Top < 0) then Shape5.Top:=Form1.Height-TrackBar1.Height; end;
Right: begin Shape5.left:=Shape5.left+(x+2); if (Shape5.Left > Form1.Width) then Shape5.Left:=0; end;
Down: begin Shape5.Top:=Shape5.Top+(x+2); if (Shape5.Top > Form1.Height-TrackBar1.Height) then Shape5.Top:=0; end;
end;
end;
procedure TrackBar1OnChange;
begin
Timer1.Stop;
case TrackBar1.Position of
0: x:=1;
1: x:=2;
2: x:=3;
3: x:=4;
4: x:=5;
end;
Timer1.Start;
end;
procedure Button1OnClick;
begin
if (Timeron = true) then begin timeron:=false; Timer1.Stop; end
else begin timeron:=true; Timer1.Start; end;
end;
procedure Form1OnCreate;
begin
x:=2;
wins:=0;
faults:=0;
faulting:=false;
Go:=true;
timeron:=true;
end;
procedure InitControls;
begin
Form1:= Form.Create(0,0,640,533);
Form1.InitControl(True,False,alNone,crDefault,clBtnFace,'Ïåðåéäè äîðîãó','');
Shape1:= Shape.Create(Form1,32,288,65,41);
Shape1.InitControl(True,True,alNone,crDefault,0,'0','');
Shape2:= Shape.Create(Form1,408,216,73,49);
Shape2.InitControl(True,True,alNone,crDefault,0,'0','');
Shape3:= Shape.Create(Form1,224,136,41,49);
Shape3.InitControl(True,True,alNone,crDefault,0,'0','');
Shape4:= Shape.Create(Form1,472,64,73,49);
Shape4.InitControl(True,True,alNone,crDefault,0,'0','');
Shape5:= Shape.Create(Form1,288,384,33,33);
Shape5.InitControl(True,True,alNone,crDefault,0,'0','');
Panel1:= Panel.Create(Form1,0,448,625,49);
Panel1.InitControl(True,True,alNone,crDefault,clBtnFace,'','');
TextLabel1:= TextLabel.Create(Panel1,8,32,48,13);
TextLabel1.InitControl(True,True,alNone,crDefault,clBtnFace,'Ñêîðîñòü','');
TextLabel2:= TextLabel.Create(Panel1,160,8,35,13);
TextLabel2.InitControl(True,True,alNone,crDefault,clBtnFace,'Ïîáåä:','');
TextLabel3:= TextLabel.Create(Panel1,160,24,40,13);
TextLabel3.InitControl(True,True,alNone,crDefault,clBtnFace,'Àâàðèé:','');
TextLabel4:= TextLabel.Create(Panel1,208,8,6,13);
TextLabel4.InitControl(True,True,alNone,crDefault,clBtnFace,'0','');
TextLabel5:= TextLabel.Create(Panel1,208,24,6,13);
TextLabel5.InitControl(True,True,alNone,crDefault,clBtnFace,'0','');
TextLabel6:= TextLabel.Create(Panel1,376,8,138,29);
TextLabel6.InitControl(True,True,alNone,crDefault,clBtnFace,'Îñòîðîæíî!','');
TrackBar1:= TrackBar.Create(Panel1,0,0,150,25);
TrackBar1.InitControl(True,True,alNone,crDefault,clBtnFace,'TrackBar1','');
Button1:= Button.Create(Panel1,240,8,75,25);
Button1.InitControl(True,True,alNone,crDefault,0,'Play/Pause','');
Timer1:= Timer.Create;
Timer1.Interval:= 10;
Shape2.Shape:= stEllipse;
Shape4.Shape:= stEllipse;
Shape5.Shape:= stCircle;
TextLabel6.Font.Color:= clRed;
TextLabel6.Font.Size:= 18;
TrackBar1.Max:= 5;
TrackBar1.Position:= 0;
TrackBar1.MarkerSize:= 20;
TrackBar1.TickMarks:= tmBottomRight;
Form1.OnCreate:=Form1OnCreate;
Form1.OnKeyDown:=KeyDown;
TrackBar1.OnChange:=TrackBar1OnChange;
Button1.OnClick:=Button1OnClick;
Timer1.OnTimer:=Timer1OnTimer;
Form1.Position:= poScreenCenter;
Form1.OnCreate;
Form1.Show;
Timer1.Start;
end;
begin
InitControls;
end.