You are on page 1of 3

unit suspensor;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
Timer1: TTimer;
Image1: TImage;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
t: integer = 0;
box: integer;
x: integer = 0;
y: integer = 0;
px: integer=0;
boxx, boxy: integer;
dir :boolean;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);


begin
with form1.image1.canvas do
begin
fillrect(clientrect);
pen.width := 1;

brush.Color:=rgb(200,200,200);
rectangle(0,220,160,250);

brush.Color:=rgb(200,200,200);
rectangle(260,220,490,250);

brush.Color:=rgb(200,200,200);
rectangle(20,20,470,30);

case box of
0: begin
if y<74 then
begin
y:=y+1;
end
else
box:=1;
end;
1: begin
if px<2 then
begin
px:=px+1;
end
else
box:=2;
end;
2: begin
if y>0 then
begin
y:=y-1; boxy:=boxy-1;
end
else
box:=3;
end;
3: begin
if x<215 then
begin
x:=x+1; boxx:=boxx+1;
end
else
box:=4;
end;
4: begin
if y<74 then
begin
y:=y+1; boxy:=boxy+1;
end
else
box:=5;
end;
5: begin
if px>0 then
begin
px:=px-1;
end
else
box:=6;
end;
6: begin
if y>0 then
begin
y:=y-1;
end
else
box:=7;
end;
7: begin
if x>0 then
begin
x:= x-1; boxx:=boxx+1;
end
else
box:=8;
end;
8: begin
x:= 0;
y:= 0;
px:= 0;
boxx:= 0;
boxy:= 0;
box:= 0;
end;
end;

brush.Color:=rgb(200, 200, 20);


rectangle(65+x, 10, 125+x, 20);
brush.Color:=clOlive;
ellipse(55+x, 5, 70+x, 20);
brush.Color:=clOlive;
ellipse(115+x, 5, 130+x, 20);

brush.Color:=rgb(0,0,0);
rectangle(94+x, 20, 96+x, 100+y);

brush.Color:=rgb(0,0,0);
rectangle(65+x, 100+y, 125+x, 104+y);

brush.Color:=rgb(200,200,20);
rectangle(65+px+x, 104+y, 68+px+x, 112+y);
brush.Color:=rgb(200,200,20);
rectangle(122-px+x, 104+y, 125-px+x, 112+y);

Form1.Image1.Canvas.Brush.Color:=clwhite;

if dir then
begin
t:=t+1;
end
else
begin
t:=t-1;
end;

if (t>190) or (t<0)then dir:= not dir;

end;
end;

procedure TForm1.Button1Click(Sender: TObject);


begin
timer1.enabled:=not (timer1.enabled);
end;

procedure TForm1.Button2Click(Sender: TObject);


begin
form1.close
end;

end.

You might also like