unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
jpeg, ExtCtrls, ComCtrls, StdCtrls, MPlayer;
type
TForm1 =
class(TForm)
Timer1: TTimer;
Image1: TImage;
ImFee1: TImage;
ProgressBar1: TProgressBar;
Label1: TLabel;
MediaPlayer1: TMediaPlayer;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ImFee1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private-Deklarationen }
procedure CreateNewDirection;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
vx, vy: integer;
Counter_zSec: Integer = 0;
Counter_Sec: Integer = 0;
highscore : Integer = 0;
const
SEC = 10;
implementation
{$R *.DFM}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
ImFee1.visible:=true;
ImFee1.Left := ImFee1.Left + vx;
ImFee1.Top := ImFee1.Top + vy;
inc(Counter_zSec);
if Counter_zSec
mod 5 = 0
then
begin
inc(Counter_Sec);
ProgressBar1.Position := Counter_Sec;
ProgressBar1.Perform($0409, 0, clTeal);
end;
if (ImFee1.Left > Image1.Width - ImFee1.Width - 1)
or (ImFee1.Left < 1)
then
vx := vx * -1;
if (ImFee1.Top > Image1.Height - ImFee1.Height - 1)
or (ImFee1.Top < 1)
then
vy := vy * -1;
if Counter_Sec = 10
then
begin
Form1.Caption:=('
Spiel ist vorbei');
ImFee1.Visible := false;
Timer1.Enabled := false;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Randomize;
DoubleBuffered := true;
ProgressBar1.Max := 10;
CreateNewDirection;
end;
procedure TForm1.CreateNewDirection;
begin
vx := -10 + Random(50);
vy := -10 + Random(50);
end;
procedure TForm1.ImFee1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ImFee1.Visible := false;
mediaplayer1.play;
CreateNewDirection;
ImFee1.Left := Random(Image1.Width-ImFee1.Width);
ImFee1.Top := random(Image1.Height - ImFee1.Height);
highscore := highscore + 10;
Label1.Caption := '
Highscore: ' + IntToStr(highscore);
end;
end.