unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Timer1: TTimer;
Image1: TImage;
procedure Button4Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2KeyPress(Sender: TObject;
var Key: Char);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
x,y,breite:integer;
implementation
{$R *.dfm}
procedure TForm1.Button4Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
timer1.enabled:=true;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
timer1.Enabled:=false;
end;
procedure TForm1.Button2KeyPress(Sender: TObject;
var Key: Char);
begin
if key='
s'
then if button1.Top < (image1.Top+image1.Height-20)
then button1.Top:=button1.top+10;
if key='
w'
then if(button1.Top > image1.Top)
then button1.Top:=button1.Top-10;
end;
procedure pause (zeit:longint);
var merke_zeit1:longint;
begin
merke_zeit1:=GettickCount;
repeat
Application.processMessages;
until (GettickCount-merke_zeit1>zeit);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
x:=601;
randomize;
breite:=random(50);
y:=random(200)+1;
image1.canvas.Rectangle(x,y,x+breite,y+breite);
repeat
pause(10);
x:=x-25;
with image1.Canvas
do
begin
brush.Color:=clgreen;
Rectangle(x,y,x+breite,y+breite);
pause (90);
brush.Color:=clskyblue;
Rectangle(-10,-10,700,250);
end;
until x<-10;
end;
end.