unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
jpeg, ExtCtrls, ComCtrls;
type
TForm1 =
class(TForm)
Timer1: TTimer;
Image1: TImage;
ImLaura: TImage;
ImFee1: TImage;
ProgressBar1: TProgressBar;
procedure FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
vx, vy: integer;
Counter_Sec: Integer = 0;
StopTimer: boolean = false;
implementation
{$R *.DFM}
procedure TForm1.FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
case Key
of
VK_LEFT:
begin
ImLaura.Left := ImLaura.Left - 5;
Key := 0;
end;
VK_RIGHT:
begin
ImLaura.Left := ImLaura.Left + 5;
Key := 0;
end;
VK_UP:
begin
ImLaura.Top := ImLaura.Top - 5;
Key := 0;
end;
VK_DOWN:
begin
ImLaura.Top := ImLaura.Top + 5;
Key := 0;
end;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if not StopTimer
then
begin
ImFee1.visible:=true;
ImFee1.Left := ImFee1.Left + vx;
ImFee1.Top := ImFee1.Top + vy;
inc(Counter_Sec);
ProgressBar1.Position := Counter_Sec;
ProgressBar1.Perform($0409, 0, clTeal);
if (ImFee1.Left > ClientWidth - ImFee1.Width - 1)
or (ImFee1.Left < 1)
then
vx := vx * -1;
if (ImFee1.Top > ClientHeight - ImFee1.Height - 1)
or (ImFee1.Top < 1)
then
vy := vy * -1;
if Counter_Sec = 10
then
begin
ImFee1.visible:=false;
ImLaura.visible:=false;
Timer1.Interval:=0;
Form1.Caption:=('
Spiel ist vorbei');
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Randomize;
vx := -10 + Random(50);
vy := -10 + Random(50);
ProgressBar1.Max := 10;
end;
procedure TForm1.FormClick(Sender: TObject);
begin
StopTimer := true;
ImFee1.Visible := false;
end;
end.