unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.ExtCtrls,
Vcl.Imaging.pngimage,
Vcl.Menus,
Vcl.StdCtrls,
Vcl.Buttons;
type
TForm1 =
class(TForm)
Image1: TImage;
Label3: TLabel;
SpeedButton1: TSpeedButton;
Label7: TLabel;
Label14: TLabel;
Label13: TLabel;
Label12: TLabel;
Label11: TLabel;
Label10: TLabel;
Label5: TLabel;
Label6: TLabel;
Label9: TLabel;
Label8: TLabel;
Label2: TLabel;
Label1: TLabel;
Label4: TLabel;
Timer1: TTimer;
Memo1: TMemo;
Memo2: TMemo;
Label15: TLabel;
Label16: TLabel;
procedure FormKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
procedure SpeedButton1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure labelmove(labe: Tlabel);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
gamestarted: boolean; gamestartclick, punktetemporär, imagetop, buttonspace, labelspace, imagespace, zeit, zufallslabel: integer;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.Lines.Clear;
memo2.Lines.Clear;
memo1.Lines.LoadFromFile('
languages\session-language.txt');
memo2.Lines.LoadFromFile('
languages\' + memo1.Lines[0] + '
.lang');
Form1.Caption:=memo2.Lines[0];
Speedbutton1.Caption:=memo2.Lines[1];
Schlieen1.Caption:=memo2.Lines[3];
Spiel1.Caption:=memo2.Lines[2];
Einstellungen1.Caption:=memo2.lines[4];
N1.Caption:=memo2.lines[5];
Spieleinstellungen1.Caption:=memo2.Lines[6];
Hilfe1.Caption:=memo2.lines[7];
Benutzung1.Caption:=memo2.lines[8];
ber1.Caption:=memo2.lines[9];
gamestartclick:=0;
timer1.interval:=50;
zeit:=0;
punktetemporär:=0;
randomize;
imagetop:=Image1.Top;
imagespace:=Image1.Left + Image1.Width;
buttonspace:=Speedbutton1.Width;
labelspace:=label1.Left;
Label1.Font.Color:=clblack;
Label2.Font.Color:=clblack;
Label3.Font.Color:=clblack;
Label4.Font.Color:=clblack;
Label5.Font.Color:=clblack;
Label6.Font.Color:=clblack;
Label7.Font.Color:=clblack;
Label8.Font.Color:=clblack;
Label9.Font.Color:=clblack;
Label10.Font.Color:=clblack;
Label11.Font.Color:=clblack;
Label12.Font.Color:=clblack;
Label13.Font.Color:=clblack;
Label14.Font.Color:=clblack;
end;
procedure TForm1.FormKeyDown(Sender: TObject;
var Key: word;
Shift: TShiftState);
begin
if gamestarted=true
then
begin
case Key
of
VK_UP:
if image1.Top - 50 <0
then
begin
image1.Top := image1.Top;
end else image1.Top := image1.Top - 50;
VK_DOWN:
if image1.Top + 475 > Form1.Height
then
begin
image1.Top := image1.Top
end else image1.Top := image1.Top + 50;
end;
end;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
gamestartclick:= gamestartclick + 1;
if ((gamestarted=False)
and (gamestartclick
mod 2 = 1))
then
begin
gamestarted:=True;
timer1.Enabled:=True;
Speedbutton1.Enabled:=False;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var i, hochzählen: integer;
begin
zeit:=zeit+1;
if zeit = 40
then
begin
zufallslabel:=random(14)+1;
end;
if zufallslabel=1
then
begin
labelmove(Label1);
if ((((Label1.Left <= imagespace)
and (Label1.Left >= (imagespace-32))))
and ((Image1.Top=imagetop+(50*8))
or (Image1.Top=imagetop+(50*7))))
then
begin
Label1.Left:=labelspace;
Label1.Font.Color:=clblack;
punktetemporär:=punktetemporär + 10;
Label16.Caption:='
' + inttostr(punktetemporär);
zufallslabel:=random(14)+1;
end;
end;
if zufallslabel=2
then
begin
if ((((Label2.Left <= imagespace)
and (Label2.Left >= (imagespace-32))))
and ((Image1.Top=imagetop+(50*8))
or (Image1.Top=imagetop+(50*7))
or (Image1.Top=imagetop+(50*6))
or (Image1.Top=imagetop+(50*5))))
then
begin
Label2.Left:=labelspace;
Label2.Font.Color:=clblack;
punktetemporär:=punktetemporär + 10;
Label16.Caption:='
' + inttostr(punktetemporär);
zufallslabel:=random(14)+1;
end;
end;
if zufallslabel=3
then
begin
labelmove(Label3);
if ((((Label3.Left <= imagespace)
and (Label3.Left >= (imagespace-32))))
and ((Image1.Top=imagetop+(50*8))
or (Image1.Top=imagetop+(50*7))
or (Image1.Top=imagetop+(50*6))
or (Image1.Top=imagetop+(50*5))
or (Image1.Top=imagetop+(50*4))))
then
begin
Label3.Left:=labelspace;
Label3.Font.Color:=clblack;
punktetemporär:=punktetemporär + 10;
Label16.Caption:='
' + inttostr(punktetemporär);
zufallslabel:=random(14)+1;
end;
end;
if zufallslabel=4
then
begin
labelmove(Label4);
if ((((Label4.Left <= imagespace)
and (Label4.Left >= (imagespace-32))))
and ((Image1.Top=imagetop+(50*8))
or (Image1.Top=imagetop+(50*7))
or (Image1.Top=imagetop+(50*6))
or (Image1.Top=imagetop+(50*5))
or (Image1.Top=imagetop+(50*4))
or (Image1.Top=imagetop+(50*3))
or (image1.Top=imagetop+(50*2))))
then
begin
Label4.Left:=labelspace;
Label4.Font.Color:=clblack;
punktetemporär:=punktetemporär + 10;
Label16.Caption:='
' + inttostr(punktetemporär);
zufallslabel:=random(14)+1;
end;
end;
if zufallslabel=5
then
begin
labelmove(Label5);
if ((((Label5.Left <= imagespace)
and (Label5.Left >= (imagespace-32))))
and ((Image1.Top=imagetop+(50*6))
or (Image1.Top=imagetop+(50*5))
or (Image1.Top=imagetop+(50*4))
or (Image1.Top=imagetop+(50*3))
or (Image1.Top=imagetop+(50*2))
or (Image1.Top=imagetop+(50*1))))
then
begin
Label5.Left:=labelspace;
Label5.Font.Color:=clblack;
punktetemporär:=punktetemporär + 10;
Label16.Caption:='
' + inttostr(punktetemporär);
zufallslabel:=random(14)+1;
end;
end;
if zufallslabel=6
then
begin
labelmove(Label6);
if ((((Label6.Left <= imagespace)
and (Label6.Left >= (imagespace-32))))
and ((Image1.Top=imagetop+(50*5))
or (Image1.Top=imagetop+(50*4))
or (Image1.Top=imagetop+(50*3))
or (Image1.Top=imagetop+(50*2))
or (Image1.Top=imagetop+(50*1))
or (Image1.Top=imagetop+(50*0))
or (Image1.Top=imagetop+(50*(-1)))))
then
begin
Label6.Left:=labelspace;
Label6.Font.Color:=clblack;
punktetemporär:=punktetemporär + 10;
Label16.Caption:='
' + inttostr(punktetemporär);
zufallslabel:=random(14)+1;
end;
end;
if zufallslabel=7
then
begin
labelmove(Label7);
if ((((Label7.Left <= imagespace)
and (Label7.Left >= (imagespace-32))))
and ((Image1.Top=imagetop+(50*3))
or (Image1.Top=imagetop+(50*2))
or (Image1.Top=imagetop+(50*1))
or (Image1.Top=imagetop+(50*0))
or (Image1.Top=imagetop+(50*(-1)))
or (Image1.Top=imagetop+(50*(-2)))))
then
begin
Label7.Left:=labelspace;
Label7.Font.Color:=clblack;
punktetemporär:=punktetemporär + 10;
Label16.Caption:='
' + inttostr(punktetemporär);
zufallslabel:=random(14)+1;
end;
end;
if zufallslabel=8
then
begin
labelmove(Label8);
if ((((Label8.Left <= imagespace)
and (Label8.Left >= (imagespace-32))))
and ((Image1.Top=imagetop+(50*2))
or (Image1.Top=imagetop+(50*1))
or (Image1.Top=imagetop+(50*0))
or (Image1.Top=imagetop+(50*(-1)))
or (Image1.Top=imagetop+(50*(-2)))
or (Image1.Top=imagetop+(50*(-3)))
or (Image1.Top=imagetop+(50*(-4)))))
then
begin
Label8.Left:=labelspace;
Label8.Font.Color:=clblack;
punktetemporär:=punktetemporär + 10;
Label16.Caption:='
' + inttostr(punktetemporär);
zufallslabel:=random(14)+1;
end;
end;
if zufallslabel=9
then
begin
labelmove(Label9);
if ((((Label9.Left <= imagespace)
and (Label9.Left >= (imagespace-32))))
and ((Image1.Top=imagetop+(50*0))
or (Image1.Top=imagetop+(50*(-1)))
or (Image1.Top=imagetop+(50*(-2)))
or (Image1.Top=imagetop+(50*(-3)))
or (Image1.Top=imagetop+(50*(-4)))
or (Image1.Top=imagetop+(50*(-5)))))
then
begin
Label9.Left:=labelspace;
Label9.Font.Color:=clblack;
punktetemporär:=punktetemporär + 10;
Label16.Caption:='
' + inttostr(punktetemporär);
zufallslabel:=random(14)+1;
end;
end;
if zufallslabel=10
then
begin
labelmove(Label10);
if ((((Label10.Left <= imagespace)
and (Label10.Left >= (imagespace-32))))
and ((Image1.Top=imagetop+(50*(-1)))
or (Image1.Top=imagetop+(50*(-2)))
or (Image1.Top=imagetop+(50*(-3)))
or (Image1.Top=imagetop+(50*(-4)))
or (Image1.Top=imagetop+(50*(-5)))
or (Image1.Top=imagetop+(50*(-6)))
or (Image1.Top=imagetop+(50*(-7)))))
then
begin
Label10.Left:=labelspace;
Label10.Font.Color:=clblack;
punktetemporär:=punktetemporär + 10;
Label16.Caption:='
' + inttostr(punktetemporär);
zufallslabel:=random(14)+1;
end;
end;
if zufallslabel=11
then
begin
labelmove(Label11);
if ((((Label11.Left <= imagespace)
and (Label11.Left >= (imagespace-32))))
and ((Image1.Top=imagetop+(50*(-3)))
or (Image1.Top=imagetop+(50*(-4)))
or (Image1.Top=imagetop+(50*(-5)))
or (Image1.Top=imagetop+(50*(-6)))
or (Image1.Top=imagetop+(50*(-7)))
or (Image1.Top=imagetop+(50*(-8)))))
then
begin
Label11.Left:=labelspace;
Label11.Font.Color:=clblack;
punktetemporär:=punktetemporär + 10;
Label16.Caption:='
' + inttostr(punktetemporär);
zufallslabel:=random(14)+1;
end;
end;
if zufallslabel=12
then
begin
labelmove(Label12);
if ((((Label12.Left <= imagespace)
and (Label12.Left >= (imagespace-32))))
and ((Image1.Top=imagetop+(50*(-4)))
or (Image1.Top=imagetop+(50*(-5)))
or (Image1.Top=imagetop+(50*(-6)))
or (Image1.Top=imagetop+(50*(-7)))
or (Image1.Top=imagetop+(50*(-8)))))
then
begin
Label12.Left:=labelspace;
Label12.Font.Color:=clblack;
punktetemporär:=punktetemporär + 10;
Label16.Caption:='
' + inttostr(punktetemporär);
zufallslabel:=random(14)+1;
end;
end;
if zufallslabel=13
then
begin
labelmove(Label13);
if ((((Label13.Left <= imagespace)
and (Label13.Left >= (imagespace-32))))
and ((Image1.Top=imagetop+(50*(-6)))
or (Image1.Top=imagetop+(50*(-7)))
or (Image1.Top=imagetop+(50*(-8)))))
then
begin
Label13.Left:=labelspace;
Label13.Font.Color:=clblack;
punktetemporär:=punktetemporär + 10;
Label16.Caption:='
' + inttostr(punktetemporär);
zufallslabel:=random(14)+1;
end;
end;
if zufallslabel=14
then
begin
labelmove(Label14);
if ((((Label14.Left <= imagespace)
and (Label14.Left >= (imagespace-32))))
and ((Image1.Top=imagetop+(50*(-7)))
or (Image1.Top=imagetop+(50*(-8)))))
then
begin
Label14.Left:=labelspace;
Label14.Font.Color:=clblack;
punktetemporär:=punktetemporär + 10;
Label16.Caption:='
' + inttostr(punktetemporär);
zufallslabel:=random(14)+1;
end;
end;
end;
procedure TForm1.labelmove(labe: Tlabel);
begin
labe.Font.Color:=clbtnface;
if labe.Left>buttonspace
then
begin
labe.Left:=labe.Left - 33;
end;
if labe.Left<=buttonspace
then
begin
Timer1.Enabled:=False;
gamestarted:=False;
punktetemporär:=0;
Label16.Caption:='
0';
gamestartclick:=0;
zeit:=0;
zufallslabel:=0;
showmessage('
Sie haben verloren.');
Speedbutton1.Enabled:=True;
Speedbutton1.Caption:='
Spiel starten';
image1.Top:=imagetop;
Label1.Left:=labelspace;
Label2.Left:=labelspace;
Label3.Left:=labelspace;
Label4.Left:=labelspace;
Label5.Left:=labelspace;
Label6.Left:=labelspace;
Label7.Left:=labelspace;
Label8.Left:=labelspace;
Label9.Left:=labelspace;
Label10.Left:=labelspace;
Label11.Left:=labelspace;
Label12.Left:=labelspace;
Label13.Left:=labelspace;
Label14.Left:=labelspace;
Label1.Font.Color:=clblack;
Label2.Font.Color:=clblack;
Label3.Font.Color:=clblack;
Label4.Font.Color:=clblack;
Label5.Font.Color:=clblack;
Label6.Font.Color:=clblack;
Label7.Font.Color:=clblack;
Label8.Font.Color:=clblack;
Label9.Font.Color:=clblack;
Label10.Font.Color:=clblack;
Label11.Font.Color:=clblack;
Label12.Font.Color:=clblack;
Label13.Font.Color:=clblack;
Label14.Font.Color:=clblack;
end;
end;
end.