unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
lcltype, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Shape1: TShape;
Shape2: TShape;
Shape3: TShape;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure Timer1Timer(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
x1,x2,state,speed,h,zero,score:integer;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Timer1Timer(Sender: TObject);
var rd:extended;
begin
if shape1.Top>=zero then state:=0;
if shape1.top<=zero-h then state:=2;
if state=1 then shape1.Top:=shape1.Top-speed;
if state=2 then shape1.Top:=shape1.Top+speed;
shape2.Left:=shape2.Left-speed;
shape3.Left:=shape3.Left-speed;
if shape2.Left<0 then shape2.Left:=form1.Width;
if shape3.Left<0 then shape3.Left:=form1.Width;
rd:=sqrt(sqr((shape1.Left+shape1.Width)-(shape2.Left+shape2.Width))+sqr((shape1.Top+shape1.Height)-(Shape2.Top+shape2.Height)));
if rd<shape1.Height then timer1.Enabled:=false;
rd:=sqrt(sqr((shape1.Left+shape1.Width)-(shape3.Left+shape3.Width))+sqr((shape1.Top+shape1.Height)-(Shape3.Top+shape3.Height)));
if rd<shape1.Height then timer1.Enabled:=false;
inc(score);
form1.Caption:=inttostr(score)+' '+floattostr(rd);
speed:=(score div 100) +1;
end;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
);
begin
if key=VK_SPACE then if state=0 then begin
state:=1;
shape1.Top:=shape1.Top-speed;
end;
if key=VK_ESCAPE then FormCreate(nil);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
timer1.Interval:=50;
timer1.Enabled:=true;
state:=0;
speed:=4;
h:=70;
zero:=176;
score:=0;
end;
end.